本文整理汇总了Java中javax.tools.StandardLocation.CLASS_OUTPUT属性的典型用法代码示例。如果您正苦于以下问题:Java StandardLocation.CLASS_OUTPUT属性的具体用法?Java StandardLocation.CLASS_OUTPUT怎么用?Java StandardLocation.CLASS_OUTPUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.tools.StandardLocation
的用法示例。
在下文中一共展示了StandardLocation.CLASS_OUTPUT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listLocationsForModules
@Override
public Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException {
if (location == StandardLocation.CLASS_OUTPUT) {
return Collections.emptySet();
} else if (location == StandardLocation.SYSTEM_MODULES) {
final ClassPath cp = JavaPlatform.getDefault().getBootstrapLibraries();
Collection<? extends URL> javaBase = findJavaBase(cp);
if (javaBase.isEmpty()) {
javaBase = fakeJavaBase(cp);
}
return Collections.singleton(Collections.singleton(new ModLoc(
StandardLocation.SYSTEM_MODULES,
"java.base", //NOI18N
javaBase)));
} else {
return Collections.emptySet();
}
}
示例2: buildUri
/**
* Builds url for a given location, class or internal name
*
* @param location java file manager location
* @param name name
* @return URI
*/
public static URI buildUri(JavaFileManager.Location location, String name) {
String extension = "";
String template = location.getName().toLowerCase().replace("_", "") + ":///%s%s";
if (location == StandardLocation.CLASS_OUTPUT) {
extension = JavaFileObject.Kind.CLASS.extension;
template = CLASS_CODE_URI_TEMPLATE;
} else if (location == StandardLocation.SOURCE_OUTPUT) {
extension = JavaFileObject.Kind.SOURCE.extension;
template = SOURCE_CODE_URI_TEMPLATE;
}
int dotLastPosition = name.lastIndexOf('.');
if (dotLastPosition != -1) {
name = name.replace('.', '/');
}
return buildUri(String.format(template, name, extension));
}
示例3: initHandlers
void initHandlers() {
handlersForLocation = new HashMap<Location, LocationHandler>();
handlersForOption = new EnumMap<Option, LocationHandler>(Option.class);
LocationHandler[] handlers = {
new BootClassPathLocationHandler(),
new ClassPathLocationHandler(),
new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCEPATH),
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSORPATH),
new OutputLocationHandler((StandardLocation.CLASS_OUTPUT), Option.D),
new OutputLocationHandler((StandardLocation.SOURCE_OUTPUT), Option.S),
new OutputLocationHandler((StandardLocation.NATIVE_HEADER_OUTPUT), Option.H)
};
for (LocationHandler h: handlers) {
handlersForLocation.put(h.location, h);
for (Option o: h.options)
handlersForOption.put(o, h);
}
}
示例4: findSingleModule
public ModuleSymbol findSingleModule() {
try {
JavaFileObject src_fo = getModuleInfoFromLocation(StandardLocation.SOURCE_PATH, Kind.SOURCE);
JavaFileObject class_fo = getModuleInfoFromLocation(StandardLocation.CLASS_OUTPUT, Kind.CLASS);
JavaFileObject fo = (src_fo == null) ? class_fo
: (class_fo == null) ? src_fo
: classFinder.preferredFileObject(src_fo, class_fo);
ModuleSymbol msym;
if (fo == null) {
msym = syms.unnamedModule;
} else {
msym = readModule(fo);
}
if (msym.patchLocation == null) {
msym.classLocation = StandardLocation.CLASS_OUTPUT;
} else {
msym.patchOutputLocation = StandardLocation.CLASS_OUTPUT;
}
return msym;
} catch (IOException e) {
throw new Error(e); // FIXME
}
}
示例5: testOutput_nested
@Test
public void testOutput_nested(Path base) throws IOException {
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
Location locn = StandardLocation.CLASS_OUTPUT;
Path out1 = Files.createDirectories(base.resolve("out1"));
fm.setLocationForModule(locn, "m", List.of(out1));
Location m = fm.getLocationForModule(locn, "m");
checkEqual("initial setting",
fm.getLocationAsPaths(m), out1);
Path out2 = Files.createDirectories(base.resolve("out2"));
checkException("create nested module",
UnsupportedOperationException.class, "not supported for CLASS_OUTPUT[m]",
() -> fm.setLocationForModule(m, "x", List.of(out2)));
}
}
示例6: getLocationForModule
@Override
public Location getLocationForModule(Location location, String moduleName) throws IOException {
if (location == StandardLocation.PATCH_MODULE_PATH) {
return moduleLocations(location).stream()
.filter((ml) -> moduleName != null && moduleName.equals(ml.getModuleName()))
.findFirst()
.orElse(null);
} else if (location == StandardLocation.CLASS_OUTPUT) {
return moduleLocations(StandardLocation.PATCH_MODULE_PATH).stream()
.filter((pl) -> moduleName != null && moduleName.equals(pl.getModuleName()))
.findFirst()
.map((pl) -> {
final List<URL> cacheRoots = pl.getSrc() == null ?
Collections.emptyList() :
pl.getSrc().getModuleRoots().stream()
.map((url) -> {
try {
return BaseUtilities.toURI(JavaIndex.getClassFolder(url, false, false)).toURL();
} catch (IOException ioe) {
LOG.log(Level.WARNING, "Cannot determine the cache URL for: {0}", url); //NOI18N
return null;
}
})
.filter((url) -> url != null)
.collect(Collectors.toList());
return cacheRoots.isEmpty() ?
null :
new PatchLocation(
StandardLocation.PATCH_MODULE_PATH,
cacheRoots,
Collections.emptyList(),
pl.getModuleName());
})
.orElse(null);
} else {
return null;
}
}
示例7: list
@Override
public Iterable<JavaFileObject> list(Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException {
if (location == StandardLocation.CLASS_OUTPUT) {
return bootstrap ?
listModuleContent(
(ModLoc) listLocationsForModules(StandardLocation.SYSTEM_MODULES).iterator().next().iterator().next(),
packageName,
kinds) :
Collections.emptyList();
} else if (location instanceof ModLoc) {
return listModuleContent((ModLoc)location, packageName, kinds);
} else {
return Collections.emptyList();
}
}
示例8: 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);
}
}
}
示例9: getModuleLocation
/**
* Determine the location for the module on the module source path
* or source output directory which contains a given CompilationUnit.
* If the source output directory is unset, the class output directory
* will be checked instead.
* {@code null} is returned if no such module can be found.
* @param tree the compilation unit tree
* @return the location for the enclosing module
* @throws IOException if there is a problem while searching for the module.
*/
private Location getModuleLocation(JCCompilationUnit tree) throws IOException {
JavaFileObject fo = tree.sourcefile;
Location loc =
fileManager.getLocationForModule(StandardLocation.MODULE_SOURCE_PATH, fo);
if (loc == null) {
Location sourceOutput = fileManager.hasLocation(StandardLocation.SOURCE_OUTPUT) ?
StandardLocation.SOURCE_OUTPUT : StandardLocation.CLASS_OUTPUT;
loc =
fileManager.getLocationForModule(sourceOutput, fo);
}
return loc;
}
示例10: testOutput
@Test
public void testOutput(Path base) throws IOException {
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
Location locn = StandardLocation.CLASS_OUTPUT;
Path out1 = Files.createDirectories(base.resolve("out1"));
fm.setLocationFromPaths(locn, List.of(out1));
Location m = fm.getLocationForModule(locn, "m");
checkEqual("default setting",
fm.getLocationAsPaths(m), out1.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 out2 = Files.createDirectories(base.resolve("out2"));
fm.setLocationFromPaths(locn, List.of(out2));
checkEqual("updated setting",
fm.getLocationAsPaths(m), out2.resolve("m"));
}
}
示例11: testOutput_invalid
@Test
public void testOutput_invalid(Path base) throws IOException {
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
Location locn = StandardLocation.CLASS_OUTPUT;
// set a top default
Path out1 = Files.createDirectories(base.resolve("out1"));
fm.setLocationFromPaths(locn, List.of(out1));
// getLocnForModule
Location m = fm.getLocationForModule(locn, "m");
checkEqual("default setting",
fm.getLocationAsPaths(m), out1.resolve("m"));
checkException("empty arg list",
IllegalArgumentException.class, "empty path for directory",
() -> fm.setLocationFromPaths(m, Collections.emptyList()));
Path out2 = Files.createDirectories(base.resolve("out2"));
checkException("empty arg list",
IllegalArgumentException.class, "path too long for directory",
() -> fm.setLocationFromPaths(m, List.of(out2, out2)));
Path notExist = base.resolve("notExist");
checkException("not exist",
FileNotFoundException.class, notExist + ": does not exist",
() -> fm.setLocationFromPaths(m, List.of(notExist)));
Path file = Files.createFile(base.resolve("file.txt"));
checkException("not exist",
IOException.class, file + ": not a directory",
() -> fm.setLocationFromPaths(m, List.of(file)));
}
}
示例12: hasLocation
@Override
public boolean hasLocation(Location location) {
return location == StandardLocation.CLASS_OUTPUT;
}
示例13: hasLocation
@Override
public boolean hasLocation(Location location) {
return (StandardLocation.PATCH_MODULE_PATH == location || StandardLocation.CLASS_OUTPUT == location)
&& !patches.isEmpty();
}
示例14: isOutputLocation
@Override
public boolean isOutputLocation() {
return base == StandardLocation.CLASS_OUTPUT;
}
示例15: hasLocation
@Override
public boolean hasLocation(Location location) {
return location == StandardLocation.CLASS_OUTPUT && outputRoot != null;
}