Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55d23e5

Browse files
committed
Handle NULL String Class Pointer
TR::Compilation::getStringClassPointer() can return NULL in an AOT compilation. Fix String Peepholes to check for NULL. Signed-off-by: Irwin D'Souza <[email protected]>
1 parent 3ebef68 commit 55d23e5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

runtime/compiler/optimizer/StringPeepholes.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,12 @@ TR::SymbolReference *TR_StringPeepholes::findSymRefForValueOf(const char *sig)
20682068
{
20692069
// try to find the symbol ref for String.valueOf
20702070
TR_OpaqueClassBlock *stringClass = comp()->getStringClassPointer();
2071-
TR_ASSERT(stringClass, "stringClass cannot be 0 because we did this before in init\n");
2071+
2072+
// It is possible for getStringClassPointer to return NULL in an AOT compilation
2073+
if (!stringClass && comp()->compileRelocatableCode())
2074+
comp()->failCompilation<TR::CompilationException>("StringPeepholes: stringClass is NULL");
2075+
2076+
TR_ASSERT_FATAL(stringClass, "stringClass should not be NULL\n");
20722077
TR_ResolvedMethod *method = comp()->fej9()->getResolvedMethodForNameAndSignature(trMemory(), stringClass, "valueOf", sig);
20732078
return method ? getSymRefTab()->findOrCreateMethodSymbol(JITTED_METHOD_INDEX, -1, method, TR::MethodSymbol::Static) : NULL;
20742079
}

0 commit comments

Comments
 (0)