本文整理汇总了Java中javax.tools.StandardLocation.MODULE_PATH属性的典型用法代码示例。如果您正苦于以下问题:Java StandardLocation.MODULE_PATH属性的具体用法?Java StandardLocation.MODULE_PATH怎么用?Java StandardLocation.MODULE_PATH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.tools.StandardLocation
的用法示例。
在下文中一共展示了StandardLocation.MODULE_PATH属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findModule
private Location findModule(String moduleName) throws IOException {
Location[] locns = {
StandardLocation.UPGRADE_MODULE_PATH,
StandardLocation.SYSTEM_MODULES,
StandardLocation.MODULE_PATH
};
for (Location segment: locns) {
for (Set<Location> set: fileManager.listLocationsForModules(segment)) {
Location result = null;
for (Location l: set) {
String name = fileManager.inferModuleName(l);
if (name.equals(moduleName)) {
if (result == null)
result = l;
else
throw new IOException("multiple definitions found for " + moduleName);
}
}
if (result != null)
return result;
}
}
return null;
}
示例2: createModuleFileManager
@NonNull
private JavaFileManager createModuleFileManager() {
if (emitted[USER_MODULES] == null) {
emitted[USER_MODULES] = new ModuleFileManager(
cap,
moduleCompile,
peersMap.getOrDefault(moduleCompile, ROOT_TO_COLLECTION),
sourceLevel,
StandardLocation.MODULE_PATH,
false);
}
return emitted[USER_MODULES];
}
示例3: createPatchFileManager
@CheckForNull
private JavaFileManager createPatchFileManager() {
if (emitted[MODULE_PATCHES] == null) {
emitted[MODULE_PATCHES] = new PatchModuleFileManager(
new ModuleFileManager(cap, ClassPath.EMPTY, ROOT_TO_COLLECTION, sourceLevel, StandardLocation.MODULE_PATH, false),
new ModuleSourceFileManager(ClassPath.EMPTY, ClassPath.EMPTY, ignoreExcludes)
);
}
return emitted[MODULE_PATCHES];
}
示例4: testList
public void testList() throws IOException {
//Source level 9, broken jar
ModuleFileManager fm = new ModuleFileManager(
CachingArchiveProvider.getDefault(),
bCp,
(u)->Collections.singleton(u),
Source.JDK1_9,
StandardLocation.MODULE_PATH,
false);
JavaFileManager.Location l = StreamSupport.stream(fm.listLocationsForModules(StandardLocation.MODULE_PATH).spliterator(), true)
.flatMap((s)->s.stream())
.findFirst()
.orElse(null);
assertNotNull(l);
Iterable<JavaFileObject> res = fm.list(l, "org.me", EnumSet.of(JavaFileObject.Kind.CLASS), false); //NOI18N
assertEquals(Arrays.asList("A Base","B Base"), toContent(res)); //NOI18N
assertEquals(Arrays.asList("org.me.A","org.me.B"), toInferedName(fm, res)); //NOI18N
//Source level 9, multi release jar
fm = new ModuleFileManager(
CachingArchiveProvider.getDefault(),
mvCp,
(u)->Collections.singleton(u),
Source.JDK1_9,
StandardLocation.MODULE_PATH,
false);
l = StreamSupport.stream(fm.listLocationsForModules(StandardLocation.MODULE_PATH).spliterator(), true)
.flatMap((s)->s.stream())
.findFirst()
.orElse(null);
assertNotNull(l);
res = fm.list(l, "org.me", EnumSet.of(JavaFileObject.Kind.CLASS), false); //NOI18N
assertEquals(Arrays.asList("A 9","B Base"), toContent(res)); //NOI18N
assertEquals(Arrays.asList("org.me.A","org.me.B"), toInferedName(fm, res)); //NOI18N
}
示例5: testListRecursive
public void testListRecursive() throws IOException {
//Source level 9, broken jar
ModuleFileManager fm = new ModuleFileManager(
CachingArchiveProvider.getDefault(),
bCp,
(u)->Collections.singleton(u),
Source.JDK1_9,
StandardLocation.MODULE_PATH,
false);
JavaFileManager.Location l = StreamSupport.stream(fm.listLocationsForModules(StandardLocation.MODULE_PATH).spliterator(), true)
.flatMap((s)->s.stream())
.findFirst()
.orElse(null);
assertNotNull(l);
Iterable<JavaFileObject> res = fm.list(l, "", EnumSet.of(JavaFileObject.Kind.CLASS), true); //NOI18N
assertEquals(Arrays.asList("A Base", "B Base", "N Base"), toContent(res)); //NOI18N
assertEquals(Arrays.asList("org.me.A", "org.me.B", "org.nb.N"), toInferedName(fm, res)); //NOI18N
//Source level 9, multi release jar
fm = new ModuleFileManager(
CachingArchiveProvider.getDefault(),
mvCp,
(u)->Collections.singleton(u),
Source.JDK1_9,
StandardLocation.MODULE_PATH,
false);
l = StreamSupport.stream(fm.listLocationsForModules(StandardLocation.MODULE_PATH).spliterator(), true)
.flatMap((s)->s.stream())
.findFirst()
.orElse(null);
assertNotNull(l);
res = fm.list(l, "", EnumSet.of(JavaFileObject.Kind.CLASS), true); //NOI18N
assertEquals(Arrays.asList("A 9", "B Base", "N Base"), toContent(res)); //NOI18N
assertEquals(Arrays.asList("org.me.A", "org.me.B", "org.nb.N"), toInferedName(fm, res)); //NOI18N
}
示例6: testGetJavaFileForInput
public void testGetJavaFileForInput() throws IOException {
//Source level 9, broken jar
ModuleFileManager fm = new ModuleFileManager(
CachingArchiveProvider.getDefault(),
bCp,
(u)->Collections.singleton(u),
Source.JDK1_9,
StandardLocation.MODULE_PATH,
false);
JavaFileManager.Location l = StreamSupport.stream(fm.listLocationsForModules(StandardLocation.MODULE_PATH).spliterator(), true)
.flatMap((s)->s.stream())
.findFirst()
.orElse(null);
assertNotNull(l);
JavaFileObject res = fm.getJavaFileForInput(l, "org.me.A", JavaFileObject.Kind.CLASS);
assertEquals(Arrays.asList("A Base"), toContent(Collections.<JavaFileObject>singleton(res))); //NOI18N
assertEquals(Arrays.asList("org.me.A"), toInferedName(fm, Collections.<JavaFileObject>singleton(res))); //NOI18N
//Source level 9, multi release jar
fm = new ModuleFileManager(
CachingArchiveProvider.getDefault(),
mvCp,
(u)->Collections.singleton(u),
Source.JDK1_9,
StandardLocation.MODULE_PATH,
false);
l = StreamSupport.stream(fm.listLocationsForModules(StandardLocation.MODULE_PATH).spliterator(), true)
.flatMap((s)->s.stream())
.findFirst()
.orElse(null);
assertNotNull(l);
res = fm.getJavaFileForInput(l, "org.me.A", JavaFileObject.Kind.CLASS);
assertEquals(Arrays.asList("A 9"), toContent(Collections.<JavaFileObject>singleton(res))); //NOI18N
assertEquals(Arrays.asList("org.me.A"), toInferedName(fm, Collections.<JavaFileObject>singleton(res))); //NOI18N
}
示例7: initHandlers
void initHandlers() {
handlersForLocation = new HashMap<>();
handlersForOption = new EnumMap<>(Option.class);
BasicLocationHandler[] handlers = {
new BootClassPathLocationHandler(),
new ClassPathLocationHandler(),
new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCE_PATH),
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSOR_PATH),
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, Option.PROCESSOR_MODULE_PATH),
new OutputLocationHandler(StandardLocation.CLASS_OUTPUT, Option.D),
new OutputLocationHandler(StandardLocation.SOURCE_OUTPUT, Option.S),
new OutputLocationHandler(StandardLocation.NATIVE_HEADER_OUTPUT, Option.H),
new ModuleSourcePathLocationHandler(),
new PatchModulesLocationHandler(),
new ModulePathLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADE_MODULE_PATH),
new ModulePathLocationHandler(StandardLocation.MODULE_PATH, Option.MODULE_PATH),
new SystemModulesLocationHandler(),
};
for (BasicLocationHandler h : handlers) {
handlersForLocation.put(h.location, h);
for (Option o : h.options) {
handlersForOption.put(o, h);
}
}
}
示例8: testModulePath
@Test
public void testModulePath(Path base) throws IOException {
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
Path src = base.resolve("src");
Path src_m = src.resolve("m");
tb.writeJavaFiles(src_m, "module m { }");
Location locn = StandardLocation.MODULE_PATH;
Path modules1 = Files.createDirectories(base.resolve("modules1"));
new JavacTask(tb)
.outdir(modules1)
.options("--module-source-path", src.toString())
.files(tb.findJavaFiles(src))
.run();
fm.setLocationFromPaths(locn, List.of(modules1));
Location m = fm.getLocationForModule(locn, "m");
checkEqual("default setting",
fm.getLocationAsPaths(m), modules1.resolve("m"));
Path override1 = Files.createDirectories(base.resolve("override1"));
fm.setLocationForModule(locn, "m", List.of(override1));
checkEqual("override setting 1",
fm.getLocationAsPaths(m), override1);
Path override2 = Files.createDirectories(base.resolve("override2"));
fm.setLocationFromPaths(m, List.of(override2));
checkEqual("override setting 2",
fm.getLocationAsPaths(m), override2);
Path modules2 = Files.createDirectories(base.resolve("modules2"));
fm.setLocationFromPaths(locn, List.of(modules2));
checkEqual("updated setting",
fm.getLocationAsPaths(m), modules2.resolve("m"));
}
}