Skip to content

Commit 89d6cb1

Browse files
committed
fix illegal-access behaviour part1
This is the first set of changes to address illegal-access behaviour. The illegal-access (--illegal-access=[permit|debug|warn]) option opens all packages in the runtime image to unnamed modules if those package existed in JDK8. The previous implementation also provided add-reads access to all modules which is incorrect. The 'if that package existed in JDK8' part will be addressed in a future PR. The default behaviour in JDK9 is '--illegal-access=permit'. In order to turn this off one must supply '--illegal-access=deny', which will be the default for Java10+ java releases. Signed-off-by: tajila <[email protected]>
1 parent 790f81d commit 89d6cb1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

runtime/util/modularityHelper.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ isPackageExportedToModuleHelper(J9VMThread *currentThread, J9Module *fromModule,
267267
*/
268268
isExported = (*targetPtr == toModule);
269269
}
270+
} else if (J9_ARE_NO_BITS_SET(vm->runtimeFlags, J9_RUNTIME_DENY_ILLEGAL_ACCESS)) {
271+
/* in Java9 --illegal-access=permit is turned on by default. This opens
272+
* each package to all-unnamed modules unless illegal-access=deny is specified
273+
*/
274+
isExported = TRUE;
270275
}
271276
}
272277
return isExported;

runtime/vm/visible.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ checkVisibility(J9VMThread *currentThread, J9Class* sourceClass, J9Class* destCl
6464
&& (J2SE_VERSION(vm) >= J2SE_19)
6565
&& J9_ARE_ALL_BITS_SET(vm->runtimeFlags, J9_RUNTIME_JAVA_BASE_MODULE_CREATED)
6666
&& !J9ROMCLASS_IS_PRIMITIVE_TYPE(destClass->romClass)
67-
&& J9_ARE_ALL_BITS_SET(vm->runtimeFlags, J9_RUNTIME_DENY_ILLEGAL_ACCESS)
6867
) {
6968
j9object_t srcClassObject = sourceClass->classObject;
7069
j9object_t destClassObject = destClass->classObject;

0 commit comments

Comments
 (0)