Java Code Examples for javax.tools.StandardLocation#SOURCE_OUTPUT
The following examples show how to use
javax.tools.StandardLocation#SOURCE_OUTPUT .
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: Locations.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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); } }
Example 2
Source File: Locations.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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); } }
Example 3
Source File: Locations.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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); } }
Example 4
Source File: Locations.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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); } }
Example 5
Source File: Locations.java From hottub with GNU General Public License v2.0 | 6 votes |
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); } }
Example 6
Source File: Locations.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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); } }
Example 7
Source File: Locations.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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); } }
Example 8
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 9
Source File: Modules.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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; }
Example 10
Source File: AptSourceFileManager.java From netbeans with Apache License 2.0 | 5 votes |
@Override public javax.tools.FileObject getFileForOutput(Location l, String pkgName, String relativeName, javax.tools.FileObject sibling) throws IOException, UnsupportedOperationException, IllegalArgumentException { URL aptRoot = getAptRoot(sibling); if (ModuleLocation.isInstance(l)) { ModuleLocation mloc = ModuleLocation.cast(l); l = mloc.getBaseLocation(); if (aptRoot == null) { final Iterator<? extends URL> it = mloc.getModuleRoots().iterator(); aptRoot = it.hasNext() ? it.next() : null; } else if (!mloc.getModuleRoots().contains(aptRoot)) { throw new UnsupportedOperationException("ModuleLocation's APT root differs from the sibling's APT root"); } } final Location location = l; if (StandardLocation.SOURCE_OUTPUT != location) { throw new UnsupportedOperationException("Only apt output is supported."); // NOI18N } if (aptRoot == null) { throw new UnsupportedOperationException(noAptRootDebug(sibling)); } final String nameStr = pkgName.length() == 0 ? relativeName : pkgName.replace('.', File.separatorChar) + File.separatorChar + relativeName; //NOI18N //Always on master fs -> file is save. return Optional.ofNullable(URLMapper.findFileObject(aptRoot)) .map(fo -> { File f = FileUtil.toFile(fo); return fileTx.createFileObject(location, new File(f, nameStr), f, null, null); }).get(); }
Example 11
Source File: AptSourceFileManager.java From netbeans with Apache License 2.0 | 5 votes |
@Override public JavaFileObject getJavaFileForOutput (Location l, String className, JavaFileObject.Kind kind, javax.tools.FileObject sibling) throws IOException, UnsupportedOperationException, IllegalArgumentException { URL aptRoot = getAptRoot(sibling); if (ModuleLocation.isInstance(l)) { ModuleLocation mloc = ModuleLocation.cast(l); l = mloc.getBaseLocation(); if (aptRoot == null) { final Iterator<? extends URL> it = mloc.getModuleRoots().iterator(); aptRoot = it.hasNext() ? it.next() : null; } else if (!mloc.getModuleRoots().contains(aptRoot)) { throw new UnsupportedOperationException("ModuleLocation's APT root differs from the sibling's APT root"); } } final Location location = l; if (StandardLocation.SOURCE_OUTPUT != location) { throw new UnsupportedOperationException("Only apt output is supported."); // NOI18N } if (aptRoot == null) { throw new UnsupportedOperationException(noAptRootDebug(sibling)); } final String nameStr = className.replace('.', File.separatorChar) + kind.extension; //NOI18N //Always on master fs -> file is save. return Optional.ofNullable(URLMapper.findFileObject(aptRoot)) .map(fo -> { File f = FileUtil.toFile(fo); return fileTx.createFileObject(location, new File(f, nameStr), f, null, null); }).get(); }
Example 12
Source File: AptSourceFileManager.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Iterable<Set<Location>> listLocationsForModules(Location location) throws IOException { if (location != StandardLocation.SOURCE_OUTPUT) { throw new UnsupportedOperationException("Only apt output is supported."); // NOI18N } if (cachedModuleLocations == null) { if (moduleSourceFileManager != null) { final Set<URL> entriesUrl = new HashSet<>(); sourceRoots.entries().forEach((e) -> entriesUrl.add(e.getURL())); cachedModuleLocations = moduleSourceFileManager.sourceModuleLocations().stream() .map((ml) -> { ModuleLocation oml = ModuleLocation.create( StandardLocation.SOURCE_OUTPUT, ml.getModuleRoots().stream() .map((src) -> { try { return BaseUtilities.toURI(JavaIndex.getAptFolder(src, false)).toURL(); } catch (IOException ioe) { Exceptions.printStackTrace(ioe); return null; } }) .filter((cacheEntry) -> cacheEntry != null && entriesUrl.contains(cacheEntry)) .collect(Collectors.toSet()), ml.getModuleName()); return oml.getModuleRoots().isEmpty() ? null : Collections.singleton((Location)oml); }) .filter(locations -> locations != null) .collect(Collectors.toList()); } else { cachedModuleLocations = Collections.emptySet(); } } return cachedModuleLocations; }
Example 13
Source File: Locations.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); } } }
Example 14
Source File: Modules.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 15
Source File: ProxyFileManager.java From netbeans with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @NonNull private <T extends javax.tools.FileObject> T mark( @NonNull final T result, @NonNull JavaFileManager.Location l) throws MalformedURLException { if (ModuleLocation.isInstance(l)) { l = ModuleLocation.cast(l).getBaseLocation(); } boolean valid = true; ProcessorGenerated.Type type = null; if (l == StandardLocation.CLASS_OUTPUT) { type = ProcessorGenerated.Type.RESOURCE; } else if (l == StandardLocation.SOURCE_OUTPUT) { type = ProcessorGenerated.Type.SOURCE; } if (cfg.getSiblings().getProvider().hasSibling() && cfg.getSiblings().getProvider().isInSourceRoot()) { if (type == ProcessorGenerated.Type.SOURCE) { cfg.getProcessorGeneratedFiles().register( cfg.getSiblings().getProvider().getSibling(), result, type); } else if (type == ProcessorGenerated.Type.RESOURCE) { try { result.openInputStream().close(); } catch (IOException ioe) { //Marking only created files cfg.getProcessorGeneratedFiles().register( cfg.getSiblings().getProvider().getSibling(), result, type); } } if (!FileObjects.isValidFileName(result)) { LOG.log( Level.WARNING, "Cannot write Annotation Processor generated file: {0} ({1})", //NOI18N new Object[] { result.getName(), result.toUri() }); valid = false; } } return valid && (cfg.getProcessorGeneratedFiles().canWrite() || !cfg.getSiblings().getProvider().hasSibling()) ? result : (T) FileObjects.nullWriteFileObject((InferableJavaFileObject)result); //safe - NullFileObject subclass of both JFO and FO. }