8281006: Module::getResourceAsStream should check if the resource is open unconditionally when caller is null

Reviewed-by: alanb, erikj, mchung
This commit is contained in:
Tim Prinzing 2022-04-20 17:02:31 +00:00 committed by Mandy Chung
parent 018017a917
commit e8016f7443
8 changed files with 393 additions and 8 deletions

View file

@ -3002,9 +3002,9 @@ public final class Class<T> implements java.io.Serializable,
if (callerModule != thisModule) {
String pn = Resources.toPackageName(name);
if (thisModule.getDescriptor().packages().contains(pn)) {
if (callerModule == null && !thisModule.isOpen(pn)) {
// no caller, package not open
return false;
if (callerModule == null) {
// no caller, return true if the package is open to all modules
return thisModule.isOpen(pn);
}
if (!thisModule.isOpen(pn, callerModule)) {
// package not open to caller