Merge pull request #22516 from tajila/backport2 · eclipse-openj9/openj9@de45391
@@ -39,12 +39,14 @@ checkModuleAccess(J9VMThread *currentThread, J9JavaVM* vm, J9ROMClass* srcRomCla
3939if (srcModule != destModule) {
4040UDATA rc = ERRCODE_GENERAL_FAILURE;
4141if (!J9_ARE_ALL_BITS_SET(lookupOptions, J9_LOOK_REFLECT_CALL)) {
42+omrthread_monitor_enter(vm->classLoaderModuleAndLocationMutex);
4243if (!isAllowedReadAccessToModule(currentThread, srcModule, destModule, &rc)) {
4344Trc_VM_checkVisibility_failed_with_errortype_romclass(currentThread,
4445srcRomClass, J9UTF8_LENGTH(J9ROMCLASS_CLASSNAME(srcRomClass)), J9UTF8_DATA(J9ROMCLASS_CLASSNAME(srcRomClass)), srcModule,
4546destRomClass, J9UTF8_LENGTH(J9ROMCLASS_CLASSNAME(destRomClass)), J9UTF8_DATA(J9ROMCLASS_CLASSNAME(destRomClass)), destModule, rc, "read access not allowed");
4647result = J9_VISIBILITY_MODULE_READ_ACCESS_ERROR;
4748 }
49+omrthread_monitor_exit(vm->classLoaderModuleAndLocationMutex);
4850 }
49515052if (J9_VISIBILITY_ALLOWED == result) {
@@ -161,8 +163,8 @@ checkVisibility(J9VMThread *currentThread, J9Class* sourceClass, J9Class* destCl
161163/* Protected */
162164if (sourceClass->packageID != destClass->packageID) {
163165if (J9_ARE_ANY_BITS_SET(sourceClass->romClass->modifiers, J9AccInterface)) {
164-/* Interfaces are types, not classes, and do not have protected access to
165- * their 'superclass' (java.lang.Object)
166+/* Interfaces are types, not classes, and do not have protected access to
167+ * their 'superclass' (java.lang.Object)
166168 */
167169result = J9_VISIBILITY_NON_MODULE_ACCESS_ERROR;
168170 } else {
@@ -309,7 +311,7 @@ loadAndVerifyNestHost(J9VMThread *vmThread, J9Class *clazz, UDATA options, J9Cla
309311 */
310312cacheNestHostInClass = FALSE;
311313 }
312-while ((isCurClassHiddenNestMate)
314+while ((isCurClassHiddenNestMate)
313315&& (curClazz != curClazz->hostClass)
314316 ) {
315317/* current class is the nestmate of its hostClass, so we need to find nesthost of the hostClass. */
@@ -357,7 +359,7 @@ loadAndVerifyNestHost(J9VMThread *vmThread, J9Class *clazz, UDATA options, J9Cla
357359result = J9_VISIBILITY_NEST_HOST_DIFFERENT_PACKAGE_ERROR;
358360 } else {
359361if (hiddenNestMate) {
360-/* The nest host of hidden class does not have a nestmembers attribute that claims the hidden class.
362+/* The nest host of hidden class does not have a nestmembers attribute that claims the hidden class.
361363 * Set result to J9_VISIBILITY_ALLOWED in this case */
362364result = J9_VISIBILITY_ALLOWED;
363365 } else {
@@ -390,9 +392,9 @@ loadAndVerifyNestHost(J9VMThread *vmThread, J9Class *clazz, UDATA options, J9Cla
390392 * JVM spec updated in Java 15:
391393 * If a class has problem finding/validating its nest host, then it is its own nest host (for hidden class, the nest host is its host class).
392394 * Any exception during finding/validating the nest host is not rethrown.
393- *
394- * If canRunJavaCode is FALSE, the flag passed to internalFindClassUTF8() is J9_FINDCLASS_FLAG_EXISTING_ONLY,
395- * which tries to find the nest host in loaded classes only. It is possible that nest host is not loaded yet.
395+ *
396+ * If canRunJavaCode is FALSE, the flag passed to internalFindClassUTF8() is J9_FINDCLASS_FLAG_EXISTING_ONLY,
397+ * which tries to find the nest host in loaded classes only. It is possible that nest host is not loaded yet.
396398 * So set clazz->nestHost only when canRunJavaCode is TRUE.
397399 */
398400*nestHostFound = curClazz;