95 private int next;
96
97 // map of module name to module reference map for modules already located
98 private final Map<String, ModuleReference> cachedModules = new HashMap<>();
99
100
101 private ModulePath(Runtime.Version version,
102 boolean isLinkPhase,
103 ModulePatcher patcher,
104 Path... entries) {
105 this.releaseVersion = version;
106 this.isLinkPhase = isLinkPhase;
107 this.patcher = patcher;
108 this.entries = entries.clone();
109 for (Path entry : this.entries) {
110 Objects.requireNonNull(entry);
111 }
112 }
113
114 /**
115 * Returns a ModuleFinder that that locates modules on the file system by
116 * searching a sequence of directories and/or packaged modules. The modules
117 * may be patched by the given ModulePatcher.
118 */
119 public static ModuleFinder of(ModulePatcher patcher, Path... entries) {
120 return new ModulePath(JarFile.runtimeVersion(), false, patcher, entries);
121 }
122
123 /**
124 * Returns a ModuleFinder that that locates modules on the file system by
125 * searching a sequence of directories and/or packaged modules.
126 */
127 public static ModuleFinder of(Path... entries) {
128 return of((ModulePatcher)null, entries);
129 }
130
131 /**
132 * Returns a ModuleFinder that that locates modules on the file system by
133 * searching a sequence of directories and/or packaged modules.
134 *
135 * @param version The release version to use for multi-release JAR files
136 * @param isLinkPhase {@code true} if the link phase to locate JMOD files
137 */
138 public static ModuleFinder of(Runtime.Version version,
139 boolean isLinkPhase,
140 Path... entries) {
141 return new ModulePath(version, isLinkPhase, null, entries);
142 }
143
144
145 @Override
146 public Optional<ModuleReference> find(String name) {
147 Objects.requireNonNull(name);
148
149 // try cached modules
150 ModuleReference m = cachedModules.get(name);
151 if (m != null)
152 return Optional.of(m);
|
95 private int next;
96
97 // map of module name to module reference map for modules already located
98 private final Map<String, ModuleReference> cachedModules = new HashMap<>();
99
100
101 private ModulePath(Runtime.Version version,
102 boolean isLinkPhase,
103 ModulePatcher patcher,
104 Path... entries) {
105 this.releaseVersion = version;
106 this.isLinkPhase = isLinkPhase;
107 this.patcher = patcher;
108 this.entries = entries.clone();
109 for (Path entry : this.entries) {
110 Objects.requireNonNull(entry);
111 }
112 }
113
114 /**
115 * Returns a ModuleFinder that locates modules on the file system by
116 * searching a sequence of directories and/or packaged modules. The modules
117 * may be patched by the given ModulePatcher.
118 */
119 public static ModuleFinder of(ModulePatcher patcher, Path... entries) {
120 return new ModulePath(JarFile.runtimeVersion(), false, patcher, entries);
121 }
122
123 /**
124 * Returns a ModuleFinder that locates modules on the file system by
125 * searching a sequence of directories and/or packaged modules.
126 */
127 public static ModuleFinder of(Path... entries) {
128 return of((ModulePatcher)null, entries);
129 }
130
131 /**
132 * Returns a ModuleFinder that locates modules on the file system by
133 * searching a sequence of directories and/or packaged modules.
134 *
135 * @param version The release version to use for multi-release JAR files
136 * @param isLinkPhase {@code true} if the link phase to locate JMOD files
137 */
138 public static ModuleFinder of(Runtime.Version version,
139 boolean isLinkPhase,
140 Path... entries) {
141 return new ModulePath(version, isLinkPhase, null, entries);
142 }
143
144
145 @Override
146 public Optional<ModuleReference> find(String name) {
147 Objects.requireNonNull(name);
148
149 // try cached modules
150 ModuleReference m = cachedModules.get(name);
151 if (m != null)
152 return Optional.of(m);
|