Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore legacy Lookup.checkClassModuleVisibility() for legacy Java 9 … #3910

Merged
merged 1 commit into from
Dec 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ private static String getModuleName(Module module) {
* @param targetClass Class which the referring class is accessing
* @throws IllegalAccessException if the targetClass is not visible
*/

/*[IF Sidecar19-SE-OpenJ9]*/
static void checkClassModuleVisibility(int accessMode, Module accessModule, Class<?> targetClass) throws IllegalAccessException {
if (INTERNAL_PRIVILEGED != accessMode) {
Module targetModule = targetClass.getModule();
Expand Down Expand Up @@ -777,7 +779,34 @@ private static IllegalAccessException throwIllegalAccessException(Module accessM
/*[MSG "K0679", "Module '{0}' no access to: package '{1}' because module '{0}' can't read module '{2}'"]*/
throw new IllegalAccessException(Msg.getString(msgId, getModuleName(accessModule), targetClassPackageName, getModuleName(targetModule)));
}

/*[ELSE]
static void checkClassModuleVisibility(int accessMode, Module accessModule, Class<?> targetClass) throws IllegalAccessException {

if (INTERNAL_PRIVILEGED != accessMode) {
Module targetModule = targetClass.getModule();
String targetClassPackageName = targetClass.getPackageName();
if ((UNCONDITIONAL & accessMode) == UNCONDITIONAL) {
/* publicLookup objects can see all unconditionally exported packages. */
if (!targetModule.isExported(targetClassPackageName)) {
/*[MSG "K0676", "Module '{0}' no access to: package '{1}' which is not exported by module '{2}'"]*/
throw new IllegalAccessException(Msg.getString("K0587", getModuleName(accessModule), targetClassPackageName, getModuleName(targetModule))); //$NON-NLS-1$
}
} else if (!(
Objects.equals(accessModule, targetModule)
|| (targetModule.isExported(targetClassPackageName, accessModule) && accessModule.canRead(targetModule)))
) {
if (!targetModule.isExported(targetClassPackageName, accessModule)) {
/*[MSG "K0677", "Module '{0}' no access to: package '{1}' which is not exported by module '{2}' to module '{0}'"]*/
throw new IllegalAccessException(Msg.getString("K0677", getModuleName(accessModule), targetClassPackageName, getModuleName(targetModule))); //$NON-NLS-1$
}
// here accessModule.canRead(targetModule) must be false
/*[MSG "K0679", "Module '{0}' no access to: package '{1}' because module '{0}' can't read module '{2}'"]*/
throw new IllegalAccessException(Msg.getString("K0679", getModuleName(accessModule), targetClassPackageName, getModuleName(targetModule))); //$NON-NLS-1$
}
}
}

/*[ENDIF]*/ /* Sidecar19-SE-OpenJ9 */
/*[ENDIF]*/

/*[IF Panama]*/
Expand Down