mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8165896: Use "open" flag from JVM_DefineModule to export all module packages
Implemented VM side of open modules, which export all their packages unqualifiedly. Automatic modules and unnamed modules are treated internally as open modules. Reviewed-by: alanb, hseigel, lfoltan
This commit is contained in:
parent
d099c0815e
commit
13c24bba29
1 changed files with 7 additions and 17 deletions
|
@ -126,7 +126,7 @@ public final class Module implements AnnotatedElement {
|
||||||
|
|
||||||
// define module to VM
|
// define module to VM
|
||||||
|
|
||||||
boolean isOpen = descriptor.isOpen();
|
boolean isOpen = descriptor.isOpen() || descriptor.isAutomatic();
|
||||||
Version version = descriptor.version().orElse(null);
|
Version version = descriptor.version().orElse(null);
|
||||||
String vs = Objects.toString(version, null);
|
String vs = Objects.toString(version, null);
|
||||||
String loc = Objects.toString(uri, null);
|
String loc = Objects.toString(uri, null);
|
||||||
|
@ -1042,9 +1042,6 @@ public final class Module implements AnnotatedElement {
|
||||||
if (syncVM) {
|
if (syncVM) {
|
||||||
// throws IllegalStateException if defined to another module
|
// throws IllegalStateException if defined to another module
|
||||||
addPackage0(this, pn);
|
addPackage0(this, pn);
|
||||||
if (descriptor.isOpen() || descriptor.isAutomatic()) {
|
|
||||||
addExportsToAll0(this, pn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
extraPackages.putIfAbsent(pn, Boolean.TRUE);
|
extraPackages.putIfAbsent(pn, Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
@ -1145,8 +1142,11 @@ public final class Module implements AnnotatedElement {
|
||||||
m.implAddReads(ALL_UNNAMED_MODULE, true);
|
m.implAddReads(ALL_UNNAMED_MODULE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// exports and opens
|
// export and open packages, skipped for open and automatic
|
||||||
initExportsAndOpens(m, nameToSource, nameToModule, layer.parents());
|
// modules since they are treated as if all packages are open
|
||||||
|
if (!descriptor.isOpen() && !descriptor.isAutomatic()) {
|
||||||
|
initExportsAndOpens(m, nameToSource, nameToModule, layer.parents());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// register the modules in the boot layer
|
// register the modules in the boot layer
|
||||||
|
@ -1207,21 +1207,11 @@ public final class Module implements AnnotatedElement {
|
||||||
Map<String, Module> nameToSource,
|
Map<String, Module> nameToSource,
|
||||||
Map<String, Module> nameToModule,
|
Map<String, Module> nameToModule,
|
||||||
List<ModuleLayer> parents) {
|
List<ModuleLayer> parents) {
|
||||||
// The VM doesn't special case open or automatic modules so need to
|
|
||||||
// export all packages
|
|
||||||
ModuleDescriptor descriptor = m.getDescriptor();
|
|
||||||
if (descriptor.isOpen() || descriptor.isAutomatic()) {
|
|
||||||
assert descriptor.opens().isEmpty();
|
|
||||||
for (String source : descriptor.packages()) {
|
|
||||||
addExportsToAll0(m, source);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Set<Module>> openPackages = new HashMap<>();
|
Map<String, Set<Module>> openPackages = new HashMap<>();
|
||||||
Map<String, Set<Module>> exportedPackages = new HashMap<>();
|
Map<String, Set<Module>> exportedPackages = new HashMap<>();
|
||||||
|
|
||||||
// process the open packages first
|
// process the open packages first
|
||||||
|
ModuleDescriptor descriptor = m.getDescriptor();
|
||||||
for (Opens opens : descriptor.opens()) {
|
for (Opens opens : descriptor.opens()) {
|
||||||
String source = opens.source();
|
String source = opens.source();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue