Skip to content

Commit

Permalink
Resolve static field ref in CP if possible
Browse files Browse the repository at this point in the history
Some constant pool entries may be unresolved when attempting to relocate
a method. If the classes involved are all loaded or initialized properly
and the entry is a static field ref, then resolveStaticFieldRef() will
be able to resolve the entry, allowing relocation to proceed.

Signed-off-by: Christian Despres <[email protected]>
  • Loading branch information
cjjdespres committed Dec 6, 2024
1 parent 2aa906a commit 2e24894
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions runtime/compiler/runtime/SymbolValidationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,16 @@ TR::SymbolValidationManager::validateStaticClassFromCPRecord(uint16_t classID, u
{
J9Class *beholder = getJ9ClassFromID(beholderID);
J9ConstantPool *beholderCP = J9_CP_FROM_CLASS(beholder);

// This CP entry could still be unresolved, which would cause
// getClassOfStaticFromCP() to fail. Attempt to resolve it manually to reduce
// the chances of failure.
if (cpIndex != -1)
{
TR::VMAccessCriticalSection getClassFromConstantPool(_fej9);
_fej9->_vmFunctionTable->resolveStaticFieldRef(_fej9->vmThread(), NULL, beholderCP, cpIndex, J9_RESOLVE_FLAG_JIT_COMPILE_TIME, NULL);
}

return validateSymbol(classID, TR_ResolvedJ9Method::getClassOfStaticFromCP(_fej9, beholderCP, cpIndex));
}

Expand Down

0 comments on commit 2e24894

Please sign in to comment.