< prev index next >

src/java.base/share/classes/java/lang/reflect/Module.java

Print this page
rev 16412 : 8171855: Move package name transformations during module bootstrap into native code
Reviewed-by: alanb, acorn, lfoltan, mchung

*** 126,143 **** boolean isOpen = descriptor.isOpen(); Version version = descriptor.version().orElse(null); String vs = Objects.toString(version, null); String loc = Objects.toString(uri, null); ! Set<String> packages = descriptor.packages(); ! int n = packages.size(); ! String[] array = new String[n]; ! int i = 0; ! for (String pn : packages) { ! array[i++] = pn.replace('.', '/'); ! } ! defineModule0(this, isOpen, vs, loc, array); } /** * Create the unnamed Module for the given ClassLoader. --- 126,137 ---- boolean isOpen = descriptor.isOpen(); Version version = descriptor.version().orElse(null); String vs = Objects.toString(version, null); String loc = Objects.toString(uri, null); ! String[] packages = descriptor.packages().toArray(new String[0]); ! defineModule0(this, isOpen, vs, loc, packages); } /** * Create the unnamed Module for the given ClassLoader.
*** 787,803 **** + " not in contents"); } // update VM first, just in case it fails if (syncVM) { - String pkgInternalForm = pn.replace('.', '/'); if (other == EVERYONE_MODULE) { ! addExportsToAll0(this, pkgInternalForm); } else if (other == ALL_UNNAMED_MODULE) { ! addExportsToAllUnnamed0(this, pkgInternalForm); } else { ! addExports0(this, pkgInternalForm, other); } } // add package name to reflectivelyExports if absent Map<String, Boolean> map = reflectivelyExports --- 781,796 ---- + " not in contents"); } // update VM first, just in case it fails if (syncVM) { if (other == EVERYONE_MODULE) { ! addExportsToAll0(this, pn); } else if (other == ALL_UNNAMED_MODULE) { ! addExportsToAllUnnamed0(this, pn); } else { ! addExports0(this, pn, other); } } // add package name to reflectivelyExports if absent Map<String, Boolean> map = reflectivelyExports
*** 1019,1029 **** extraPackages = Collections.singleton(pn); } // update VM first, just in case it fails if (syncVM) ! addPackage0(this, pn.replace('.', '/')); // replace with new set this.extraPackages = extraPackages; // volatile write } } --- 1012,1022 ---- extraPackages = Collections.singleton(pn); } // update VM first, just in case it fails if (syncVM) ! addPackage0(this, pn); // replace with new set this.extraPackages = extraPackages; // volatile write } }
*** 1178,1226 **** { // The VM doesn't know about open modules so need to export all packages if (descriptor.isOpen()) { assert descriptor.opens().isEmpty(); for (String source : descriptor.packages()) { ! String sourceInternalForm = source.replace('.', '/'); ! addExportsToAll0(m, sourceInternalForm); } return; } Map<String, Set<Module>> openPackages = new HashMap<>(); Map<String, Set<Module>> exportedPackages = new HashMap<>(); // process the open packages first for (Opens opens : descriptor.opens()) { String source = opens.source(); - String sourceInternalForm = source.replace('.', '/'); if (opens.isQualified()) { // qualified opens Set<Module> targets = new HashSet<>(); for (String target : opens.targets()) { // only open to modules that are in this configuration Module m2 = nameToModule.get(target); if (m2 != null) { ! addExports0(m, sourceInternalForm, m2); targets.add(m2); } } if (!targets.isEmpty()) { openPackages.put(source, targets); } } else { // unqualified opens ! addExportsToAll0(m, sourceInternalForm); openPackages.put(source, EVERYONE_SET); } } // next the exports, skipping exports when the package is open for (Exports exports : descriptor.exports()) { String source = exports.source(); - String sourceInternalForm = source.replace('.', '/'); // skip export if package is already open to everyone Set<Module> openToTargets = openPackages.get(source); if (openToTargets != null && openToTargets.contains(EVERYONE_MODULE)) continue; --- 1171,1216 ---- { // The VM doesn't know about open modules so need to export all packages if (descriptor.isOpen()) { assert descriptor.opens().isEmpty(); for (String source : descriptor.packages()) { ! addExportsToAll0(m, source); } return; } Map<String, Set<Module>> openPackages = new HashMap<>(); Map<String, Set<Module>> exportedPackages = new HashMap<>(); // process the open packages first for (Opens opens : descriptor.opens()) { String source = opens.source(); if (opens.isQualified()) { // qualified opens Set<Module> targets = new HashSet<>(); for (String target : opens.targets()) { // only open to modules that are in this configuration Module m2 = nameToModule.get(target); if (m2 != null) { ! addExports0(m, source, m2); targets.add(m2); } } if (!targets.isEmpty()) { openPackages.put(source, targets); } } else { // unqualified opens ! addExportsToAll0(m, source); openPackages.put(source, EVERYONE_SET); } } // next the exports, skipping exports when the package is open for (Exports exports : descriptor.exports()) { String source = exports.source(); // skip export if package is already open to everyone Set<Module> openToTargets = openPackages.get(source); if (openToTargets != null && openToTargets.contains(EVERYONE_MODULE)) continue;
*** 1232,1253 **** // only export to modules that are in this configuration Module m2 = nameToModule.get(target); if (m2 != null) { // skip qualified export if already open to m2 if (openToTargets == null || !openToTargets.contains(m2)) { ! addExports0(m, sourceInternalForm, m2); targets.add(m2); } } } if (!targets.isEmpty()) { exportedPackages.put(source, targets); } } else { // unqualified exports ! addExportsToAll0(m, sourceInternalForm); exportedPackages.put(source, EVERYONE_SET); } } if (!openPackages.isEmpty()) --- 1222,1243 ---- // only export to modules that are in this configuration Module m2 = nameToModule.get(target); if (m2 != null) { // skip qualified export if already open to m2 if (openToTargets == null || !openToTargets.contains(m2)) { ! addExports0(m, source, m2); targets.add(m2); } } } if (!targets.isEmpty()) { exportedPackages.put(source, targets); } } else { // unqualified exports ! addExportsToAll0(m, source); exportedPackages.put(source, EVERYONE_SET); } } if (!openPackages.isEmpty())
< prev index next >