Java Code Examples for javax.tools.StandardLocation#SYSTEM_MODULES
The following examples show how to use
javax.tools.StandardLocation#SYSTEM_MODULES .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModuleNamesTest.java From netbeans with Apache License 2.0 | 6 votes |
@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(); } }
Example 2
Source File: JavapTask.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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; }
Example 3
Source File: SetLocationForModule.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testSystemModules(Path base) throws IOException { try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) { Location locn = StandardLocation.SYSTEM_MODULES; Location javaCompiler = fm.getLocationForModule(locn, "java.compiler"); // cannot easily verify default setting: could be jrt: or exploded image Path override1 = Files.createDirectories(base.resolve("override1")); fm.setLocationForModule(locn, "java.compiler", List.of(override1)); checkEqual("override setting 1", fm.getLocationAsPaths(javaCompiler), override1); Path override2 = Files.createDirectories(base.resolve("override2")); fm.setLocationFromPaths(javaCompiler, List.of(override2)); checkEqual("override setting 2", fm.getLocationAsPaths(javaCompiler), override2); } }
Example 4
Source File: Locations.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
void initHandlers() { handlersForLocation = new HashMap<>(); handlersForOption = new EnumMap<>(Option.class); BasicLocationHandler[] handlers = { new BootClassPathLocationHandler(StandardLocation.PLATFORM_CLASS_PATH), new BootClassPathLocationHandler(StandardLocation.SYSTEM_MODULES), new ClassFileLocationHandler(), 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 ModuleSourceFileLocationHandler(), new PatchModulesLocationHandler(), new ModuleFileLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADE_MODULE_PATH), new ModuleFileLocationHandler(StandardLocation.MODULE_PATH, Option.MODULE_PATH) }; for (BasicLocationHandler h : handlers) { handlersForLocation.put(h.location, h); for (Option o : h.options) { handlersForOption.put(o, h); } } }
Example 5
Source File: ProxyFileManager.java From netbeans with Apache License 2.0 | 5 votes |
@NonNull private JavaFileManager createSystemModuleFileManager() { if (emitted[SYS_MODULES] == null) { emitted[SYS_MODULES] = new ModuleFileManager( cap, moduleBoot, peersMap.getOrDefault(moduleBoot, ROOT_TO_COLLECTION), sourceLevel, StandardLocation.SYSTEM_MODULES, true); } return emitted[SYS_MODULES]; }
Example 6
Source File: ModuleFinder.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
private List<ModuleSymbol> scanModulePath(ModuleSymbol toFind) { ListBuffer<ModuleSymbol> results = new ListBuffer<>(); Map<Name, Location> namesInSet = new HashMap<>(); boolean multiModuleMode = fileManager.hasLocation(StandardLocation.MODULE_SOURCE_PATH); while (moduleLocationIterator.hasNext()) { Set<Location> locns = (moduleLocationIterator.next()); namesInSet.clear(); for (Location l: locns) { try { Name n = names.fromString(fileManager.inferModuleName(l)); if (namesInSet.put(n, l) == null) { ModuleSymbol msym = syms.enterModule(n); if (msym.sourceLocation != null || msym.classLocation != null) { // module has already been found, so ignore this instance continue; } if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) && msym.patchLocation == null) { msym.patchLocation = fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH, msym.name.toString()); if (msym.patchLocation != null && multiModuleMode && fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { msym.patchOutputLocation = fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT, msym.name.toString()); } } if (moduleLocationIterator.outer == StandardLocation.MODULE_SOURCE_PATH) { msym.sourceLocation = l; if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { msym.classLocation = fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT, msym.name.toString()); } } else { msym.classLocation = l; } if (moduleLocationIterator.outer == StandardLocation.SYSTEM_MODULES || moduleLocationIterator.outer == StandardLocation.UPGRADE_MODULE_PATH) { msym.flags_field |= Flags.SYSTEM_MODULE; } if (toFind == null || (toFind == msym && (msym.sourceLocation != null || msym.classLocation != null))) { // Note: cannot return msym directly, because we must finish // processing this set first results.add(msym); } } else { log.error(Errors.DuplicateModuleOnPath( getDescription(moduleLocationIterator.outer), n)); } } catch (IOException e) { // skip location for now? log error? } } if (toFind != null && results.nonEmpty()) return results.toList(); } return results.toList(); }
Example 7
Source File: ModuleNamesTest.java From netbeans with Apache License 2.0 | 4 votes |
@Override public boolean hasLocation(Location location) { return location == StandardLocation.CLASS_OUTPUT || location == StandardLocation.SYSTEM_MODULES; }
Example 8
Source File: ModuleFinder.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private List<ModuleSymbol> scanModulePath(ModuleSymbol toFind) { ListBuffer<ModuleSymbol> results = new ListBuffer<>(); Map<Name, Location> namesInSet = new HashMap<>(); boolean multiModuleMode = fileManager.hasLocation(StandardLocation.MODULE_SOURCE_PATH); while (moduleLocationIterator.hasNext()) { Set<Location> locns = (moduleLocationIterator.next()); namesInSet.clear(); for (Location l: locns) { try { Name n = names.fromString(fileManager.inferModuleName(l)); if (namesInSet.put(n, l) == null) { ModuleSymbol msym = syms.enterModule(n); if (msym.sourceLocation != null || msym.classLocation != null) { // module has already been found, so ignore this instance continue; } if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) && msym.patchLocation == null) { msym.patchLocation = fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH, msym.name.toString()); if (msym.patchLocation != null && multiModuleMode && fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { msym.patchOutputLocation = fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT, msym.name.toString()); } } if (moduleLocationIterator.outer == StandardLocation.MODULE_SOURCE_PATH) { msym.sourceLocation = l; if (fileManager.hasLocation(StandardLocation.CLASS_OUTPUT)) { msym.classLocation = fileManager.getLocationForModule(StandardLocation.CLASS_OUTPUT, msym.name.toString()); } } else { msym.classLocation = l; } if (moduleLocationIterator.outer == StandardLocation.SYSTEM_MODULES || moduleLocationIterator.outer == StandardLocation.UPGRADE_MODULE_PATH) { msym.flags_field |= Flags.SYSTEM_MODULE; } if (toFind == null || (toFind == msym && (msym.sourceLocation != null || msym.classLocation != null))) { // Note: cannot return msym directly, because we must finish // processing this set first results.add(msym); } } else { log.error(Errors.DuplicateModuleOnPath( getDescription(moduleLocationIterator.outer), n)); } } catch (IOException e) { // skip location for now? log error? } } if (toFind != null && results.nonEmpty()) return results.toList(); } return results.toList(); }
Example 9
Source File: Locations.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
SystemModulesLocationHandler() { super(StandardLocation.SYSTEM_MODULES, Option.SYSTEM); systemJavaHome = Locations.javaHome; }