Skip to content

Commit

Permalink
Use a better named static method instead of a constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
szegedi committed Dec 20, 2020
1 parent f50b852 commit db002e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ abstract class NashornLoader extends SecureClassLoader {
protected static final String SCRIPTS_PKG_INTERNAL = "org/openjdk/nashorn/internal/scripts";

static final Module NASHORN_MODULE = Context.class.getModule();
static final boolean modular = NASHORN_MODULE.getName() != null;

private static final Permission[] SCRIPT_PERMISSIONS;

Expand Down Expand Up @@ -121,6 +120,10 @@ final void addModuleExport(final Module to) {
}
}

static boolean isInNamedModule() {
return NASHORN_MODULE.getName() != null;
}

protected static void checkPackageAccess(final String name) {
final int i = name.lastIndexOf('.');
if (i != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class ScriptLoader extends NashornLoader {
super(context.getStructLoader());
this.context = context;

if (modular) {
if (isInNamedModule()) {
// new scripts module, it's specific exports and read-edges
scriptModule = createModule();

Expand Down Expand Up @@ -99,7 +99,7 @@ private Module createModule() {
protected Class<?> loadClass(final String name, final boolean resolve) throws ClassNotFoundException {
checkPackageAccess(name);
final Class<?> cl = super.loadClass(name, resolve);
if (!structureAccessAdded && modular) {
if (!structureAccessAdded && isInNamedModule()) {
final StructureLoader structLoader = context.getStructLoader();
if (cl.getClassLoader() == structLoader) {
structureAccessAdded = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class StructureLoader extends NashornLoader {
StructureLoader(final ClassLoader parent) {
super(parent);

if (modular) {
if (isInNamedModule()) {
// new structures module, it's exports, read edges
structuresModule = createModule();

Expand Down

0 comments on commit db002e6

Please sign in to comment.