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

@ -1653,11 +1653,11 @@ public final class Module implements AnnotatedElement {
if (caller != this && caller != Object.class.getModule()) {
String pn = Resources.toPackageName(name);
if (getPackages().contains(pn)) {
if (caller == null && !isOpen(pn)) {
// no caller, package not open
return null;
}
if (!isOpen(pn, caller)) {
if (caller == null) {
if (!isOpen(pn)) {
return null;
}
} else if (!isOpen(pn, caller)) {
// package not open to caller
return null;
}