< prev index next >
src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
Print this page
*** 51,60 ****
--- 51,61 ----
import static jdk.internal.module.Checks.*;
import static java.util.Objects.*;
import jdk.internal.module.Checks;
import jdk.internal.module.ModuleHashes;
+ import jdk.internal.module.WarnIfResolvedReason;
/**
* A module descriptor.
*
*** 990,999 ****
--- 991,1002 ----
private final String osName;
private final String osArch;
private final String osVersion;
private final Set<String> packages;
private final ModuleHashes hashes;
+ private final boolean doNotResolveByDefault;
+ private final WarnIfResolvedReason warnIfResolvedReason;
private ModuleDescriptor(String name,
boolean open,
boolean automatic,
*** 1007,1017 ****
String mainClass,
String osName,
String osArch,
String osVersion,
Set<String> packages,
! ModuleHashes hashes)
{
this.name = name;
this.open = open;
this.automatic = automatic;
--- 1010,1022 ----
String mainClass,
String osName,
String osArch,
String osVersion,
Set<String> packages,
! ModuleHashes hashes,
! boolean doNotResolveByDefault,
! WarnIfResolvedReason warnIfResolvedReason)
{
this.name = name;
this.open = open;
this.automatic = automatic;
*** 1030,1039 ****
--- 1035,1046 ----
this.osName = osName;
this.osArch = osArch;
this.osVersion = osVersion;
this.hashes = hashes;
this.packages = emptyOrUnmodifiableSet(packages);
+ this.doNotResolveByDefault = doNotResolveByDefault;
+ this.warnIfResolvedReason = warnIfResolvedReason;
}
/**
* Clones the given module descriptor with an augmented set of packages
*/
*** 1053,1062 ****
--- 1060,1071 ----
this.mainClass = md.mainClass;
this.osName = md.osName;
this.osArch = md.osArch;
this.osVersion = md.osVersion;
this.hashes = null; // need to ignore
+ this.doNotResolveByDefault = md.doNotResolveByDefault;
+ this.warnIfResolvedReason = md.warnIfResolvedReason;
Set<String> packages = new HashSet<>(md.packages);
packages.addAll(pkgs);
this.packages = emptyOrUnmodifiableSet(packages);
}
*** 1080,1089 ****
--- 1089,1100 ----
String osArch,
String osVersion,
Set<String> packages,
ModuleHashes hashes,
int hashCode,
+ boolean doNotResolveByDefault,
+ WarnIfResolvedReason warnIfResolvedReason,
boolean unused) {
this.name = name;
this.open = open;
this.automatic = automatic;
this.synthetic = synthetic;
*** 1098,1107 ****
--- 1109,1120 ----
this.osName = osName;
this.osArch = osArch;
this.osVersion = osVersion;
this.hashes = hashes;
this.hash = hashCode;
+ this.doNotResolveByDefault = doNotResolveByDefault;
+ this.warnIfResolvedReason = warnIfResolvedReason;
}
/**
* <p> The module name. </p>
*
*** 1289,1298 ****
--- 1302,1315 ----
*/
Optional<ModuleHashes> hashes() {
return Optional.ofNullable(hashes);
}
+ /* package */ boolean doNotResolveByDefault() {
+ return doNotResolveByDefault;
+ }
+
/**
* A builder used for building {@link ModuleDescriptor} objects.
*
* <p> {@code ModuleDescriptor} defines the {@link #module module}, {@link
*** 1332,1341 ****
--- 1349,1360 ----
String osName;
String osArch;
String osVersion;
String mainClass;
ModuleHashes hashes;
+ boolean doNotResolveByDefault;
+ WarnIfResolvedReason warnIfResolvedReason = WarnIfResolvedReason.NONE;
/**
* Initializes a new builder with the given module name.
*
* @param strict
*** 1703,1712 ****
--- 1722,1740 ----
*/
public Builder opens(String pn) {
return opens(Collections.emptySet(), pn);
}
+ /* package */ Builder doNotResolveByDefault(boolean value) {
+ this.doNotResolveByDefault = value;
+ return this;
+ }
+
+ /* package */ Builder warnIfResolved(WarnIfResolvedReason reason) {
+ this.warnIfResolvedReason = reason;
+ return this;
+ }
// Used by ModuleInfo, after a packageFinder is invoked
/* package */ Set<String> exportedAndOpenPackages() {
if (opens.isEmpty())
return exports.keySet();
*** 2011,2021 ****
mainClass,
osName,
osArch,
osVersion,
packages,
! hashes);
}
}
/**
--- 2039,2051 ----
mainClass,
osName,
osArch,
osVersion,
packages,
! hashes,
! doNotResolveByDefault,
! warnIfResolvedReason);
}
}
/**
*** 2087,2097 ****
&& Objects.equals(mainClass, that.mainClass)
&& Objects.equals(osName, that.osName)
&& Objects.equals(osArch, that.osArch)
&& Objects.equals(osVersion, that.osVersion)
&& Objects.equals(packages, that.packages)
! && Objects.equals(hashes, that.hashes));
}
private transient int hash; // cached hash code
/**
--- 2117,2129 ----
&& Objects.equals(mainClass, that.mainClass)
&& Objects.equals(osName, that.osName)
&& Objects.equals(osArch, that.osArch)
&& Objects.equals(osVersion, that.osVersion)
&& Objects.equals(packages, that.packages)
! && Objects.equals(hashes, that.hashes)
! && doNotResolveByDefault == that.doNotResolveByDefault
! && warnIfResolvedReason == that.warnIfResolvedReason);
}
private transient int hash; // cached hash code
/**
*** 2121,2130 ****
--- 2153,2164 ----
hc = hc * 43 + Objects.hashCode(osName);
hc = hc * 43 + Objects.hashCode(osArch);
hc = hc * 43 + Objects.hashCode(osVersion);
hc = hc * 43 + Objects.hashCode(packages);
hc = hc * 43 + Objects.hashCode(hashes);
+ hc = hc * 43 + Objects.hashCode(doNotResolveByDefault);
+ hc = hc * 43 + Objects.hashCode(warnIfResolvedReason);
if (hc == 0)
hc = -1;
hash = hc;
}
return hc;
*** 2446,2456 ****
String osName,
String osArch,
String osVersion,
Set<String> packages,
ModuleHashes hashes,
! int hashCode) {
return new ModuleDescriptor(name,
open,
automatic,
synthetic,
requires,
--- 2480,2492 ----
String osName,
String osArch,
String osVersion,
Set<String> packages,
ModuleHashes hashes,
! int hashCode,
! boolean doNotResolveByDefault,
! WarnIfResolvedReason reason) {
return new ModuleDescriptor(name,
open,
automatic,
synthetic,
requires,
*** 2464,2473 ****
--- 2500,2511 ----
osArch,
osVersion,
packages,
hashes,
hashCode,
+ doNotResolveByDefault,
+ reason,
false);
}
@Override
public Optional<ModuleHashes> hashes(ModuleDescriptor descriptor) {
*** 2489,2498 ****
--- 2527,2546 ----
Supplier<ModuleReader> s) {
return new ModuleReference(descriptor, location, s, true, null);
}
@Override
+ public boolean doNotResolveByDefault(ModuleDescriptor descriptor) {
+ return descriptor.doNotResolveByDefault;
+ }
+
+ @Override
+ public WarnIfResolvedReason warnIfResolvedReason(ModuleDescriptor descriptor) {
+ return descriptor.warnIfResolvedReason;
+ }
+
+ @Override
public ModuleFinder newModulePath(Runtime.Version version,
boolean isLinkPhase,
Path... entries) {
return new ModulePath(version, isLinkPhase, entries);
}
< prev index next >