< prev index next >

src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java

Print this page
rev 57943 : 8238599: Refactor and simplify implAddOpensToAllUnnamed
Reviewed-by: alanb

*** 798,807 **** --- 798,809 ---- IllegalAccessMaps maps = IllegalAccessMaps.generate(limitedFinder()); concealedPackagesToOpen = maps.concealedPackagesToOpen(); exportedPackagesToOpen = maps.exportedPackagesToOpen(); } + Set<String> emptySet = Set.of(); + // open specific packages in the system modules for (Module m : bootLayer.modules()) { ModuleDescriptor descriptor = m.getDescriptor(); String name = m.getName();
*** 814,825 **** if (upgradeModulePath != null && upgradeModulePath.find(name).isPresent()) { continue; } ! Set<String> concealedPackages = concealedPackagesToOpen.getOrDefault(name, Set.of()); ! Set<String> exportedPackages = exportedPackagesToOpen.getOrDefault(name, Set.of()); // refresh the set of concealed and exported packages if needed if (extraExportsOrOpens) { concealedPackages = new HashSet<>(concealedPackages); exportedPackages = new HashSet<>(exportedPackages); --- 816,827 ---- if (upgradeModulePath != null && upgradeModulePath.find(name).isPresent()) { continue; } ! Set<String> concealedPackages = concealedPackagesToOpen.getOrDefault(name, emptySet); ! Set<String> exportedPackages = exportedPackagesToOpen.getOrDefault(name, emptySet); // refresh the set of concealed and exported packages if needed if (extraExportsOrOpens) { concealedPackages = new HashSet<>(concealedPackages); exportedPackages = new HashSet<>(exportedPackages);
*** 848,859 **** // log reflective access to non-public members/types in exported packages builder.logAccessToExportedPackages(m, exportedPackages); // open the packages to unnamed modules JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); ! jla.addOpensToAllUnnamed(m, concat(concealedPackages.iterator(), ! exportedPackages.iterator())); } builder.complete(); } --- 850,860 ---- // log reflective access to non-public members/types in exported packages builder.logAccessToExportedPackages(m, exportedPackages); // open the packages to unnamed modules JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); ! jla.addOpensToAllUnnamed(m, concealedPackages, exportedPackages); } builder.complete(); }
*** 994,1022 **** throw new IllegalArgumentException(prefix); } } /** - * Returns an iterator that yields all elements of the first iterator - * followed by all the elements of the second iterator. - */ - static <T> Iterator<T> concat(Iterator<T> iterator1, Iterator<T> iterator2) { - return new Iterator<T>() { - @Override - public boolean hasNext() { - return iterator1.hasNext() || iterator2.hasNext(); - } - @Override - public T next() { - if (iterator1.hasNext()) return iterator1.next(); - if (iterator2.hasNext()) return iterator2.next(); - throw new NoSuchElementException(); - } - }; - } - - /** * Wraps a (potentially not thread safe) ModuleFinder created during startup * for use after startup. */ static class SafeModuleFinder implements ModuleFinder { private final Set<ModuleReference> mrefs; --- 995,1004 ----
< prev index next >