Skip to content

Commit

Permalink
Add assertion
Browse files Browse the repository at this point in the history
Signed-off-by: Gengchen Tuo <[email protected]>
  • Loading branch information
thallium committed Nov 1, 2024
1 parent 4fd6c2f commit 8d4a78d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion runtime/vm/classsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ internalFindClassString(J9VMThread* currentThread, j9object_t moduleName, j9obje
J9Class *result = NULL;
J9JavaVM* vm = currentThread->javaVM;
BOOLEAN fastMode = J9_ARE_ALL_BITS_SET(vm->extendedRuntimeFlags, J9_EXTENDED_RUNTIME_FAST_CLASS_HASH_TABLE);
PORT_ACCESS_FROM_JAVAVM(vm);

/* If -XX:+FastClassHashTable is enabled, do not lock anything to do the initial table peek */
if (!fastMode) {
Expand All @@ -334,7 +335,6 @@ internalFindClassString(J9VMThread* currentThread, j9object_t moduleName, j9obje
U_8 *utf8Name = NULL;
UDATA utf8Length = 0;
UDATA stringFlags = J9_STR_NULL_TERMINATE_RESULT;
PORT_ACCESS_FROM_JAVAVM(vm);

if (CLASSNAME_INVALID == allowedBitsForClassName) {
stringFlags |= J9_STR_XLAT;
Expand Down Expand Up @@ -382,6 +382,27 @@ internalFindClassString(J9VMThread* currentThread, j9object_t moduleName, j9obje
j9mem_free_memory(utf8Name);
}
}
if (NULL != result && !J9CLASS_IS_ARRAY(result)) {
U_8 *utf8Name = NULL;
UDATA utf8Length = 0;
U_8 localBuf[J9VM_PACKAGE_NAME_BUFFER_LENGTH];
J9UTF8 *romClassName = J9ROMCLASS_CLASSNAME(result->romClass);

utf8Name = (U_8*)copyStringToUTF8WithMemAlloc(currentThread, className, J9_STR_NULL_TERMINATE_RESULT, "", 0, (char *)localBuf, J9VM_PACKAGE_NAME_BUFFER_LENGTH, &utf8Length);
if (NULL != utf8Name) {
for (int i = 0; i < utf8Length; i++) {
if (utf8Name[i] == '.') {
utf8Name[i] = '/';
}
}
Assert_VM_true(J9UTF8_DATA_EQUALS(
J9UTF8_DATA(romClassName), J9UTF8_LENGTH(romClassName),
utf8Name, utf8Length));
if (utf8Name != localBuf) {
j9mem_free_memory(utf8Name);
}
}
}
return result;
}

Expand Down

0 comments on commit 8d4a78d

Please sign in to comment.