Java Code Examples for javax.tools.StandardLocation#PLATFORM_CLASS_PATH

The following examples show how to use javax.tools.StandardLocation#PLATFORM_CLASS_PATH . 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: ElementStructureTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException {
    if (location != StandardLocation.PLATFORM_CLASS_PATH || !kinds.contains(Kind.CLASS))
        return Collections.emptyList();

    if (!packageName.isEmpty())
        packageName += ".";

    List<JavaFileObject> result = new ArrayList<>();

    for (Entry<String, JavaFileObject> e : className2File.entrySet()) {
        String currentPackage = e.getKey().substring(0, e.getKey().lastIndexOf(".") + 1);
        if (recurse ? currentPackage.startsWith(packageName) : packageName.equals(currentPackage))
            result.add(e.getValue());
    }

    return result;
}
 
Example 2
Source File: SetLocationForModule.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testBasic(Path base) throws IOException {
    try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
        Location[] locns = {
            StandardLocation.SOURCE_PATH,
            StandardLocation.CLASS_PATH,
            StandardLocation.PLATFORM_CLASS_PATH,
        };
        // set a value
        Path out = Files.createDirectories(base.resolve("out"));
        for (Location locn : locns) {
            checkException("unsupported for location",
                    IllegalArgumentException.class,
                    "location is not an output location or a module-oriented location: " + locn,
                    () -> fm.setLocationForModule(locn, "m", List.of(out)));
        }
    }
}
 
Example 3
Source File: JavaCodeScriptEngine.java    From chaosblade-exec-jvm with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse)
    throws IOException {
    if (location == StandardLocation.PLATFORM_CLASS_PATH) {
        return super.list(location, packageName, kinds, recurse);
    } else if (location == StandardLocation.CLASS_PATH && kinds.contains(JavaFileObject.Kind.CLASS)) {
        if (packageName.startsWith("java")) {
            return super.list(location, packageName, kinds, recurse);
        } else {
            return find(packageName);
        }
    }
    return Collections.emptyList();
}
 
Example 4
Source File: Locations.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
BootClassPathLocationHandler() {
    super(StandardLocation.PLATFORM_CLASS_PATH,
            Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
            Option.XBOOTCLASSPATH_PREPEND,
            Option.XBOOTCLASSPATH_APPEND,
            Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
            Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
}
 
Example 5
Source File: Locations.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
BootClassPathLocationHandler() {
    super(StandardLocation.PLATFORM_CLASS_PATH,
            Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
            Option.XBOOTCLASSPATH_PREPEND,
            Option.XBOOTCLASSPATH_APPEND,
            Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
            Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
}
 
Example 6
Source File: MemoryBasedJavaFileManager.java    From spring-init with Apache License 2.0 5 votes vote down vote up
@Override
public boolean hasLocation(Location location) {
	logger.debug("hasLocation({})", location);
	return (location == StandardLocation.SOURCE_PATH
			|| location == StandardLocation.CLASS_PATH
			|| location == StandardLocation.PLATFORM_CLASS_PATH
			|| (this.processorPath != null && location == StandardLocation.ANNOTATION_PROCESSOR_PATH));
}
 
Example 7
Source File: Locations.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
BootClassPathLocationHandler() {
    super(StandardLocation.PLATFORM_CLASS_PATH,
            Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
            Option.XBOOTCLASSPATH_PREPEND,
            Option.XBOOTCLASSPATH_APPEND,
            Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
            Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
}
 
Example 8
Source File: Locations.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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: Locations.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
BootClassPathLocationHandler() {
    super(StandardLocation.PLATFORM_CLASS_PATH,
            Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
            Option.XBOOTCLASSPATH_PREPEND,
            Option.XBOOTCLASSPATH_APPEND,
            Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
            Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
}
 
Example 10
Source File: Locations.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
BootClassPathLocationHandler() {
    super(StandardLocation.PLATFORM_CLASS_PATH,
            Option.BOOT_CLASS_PATH, Option.XBOOTCLASSPATH,
            Option.XBOOTCLASSPATH_PREPEND,
            Option.XBOOTCLASSPATH_APPEND,
            Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
            Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
}
 
Example 11
Source File: MemoryBasedJavaFileManager.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
@Override
public boolean hasLocation(Location location) {
	logger.debug("hasLocation({})", location);
	return (location == StandardLocation.SOURCE_PATH
			|| location == StandardLocation.CLASS_PATH
			|| location == StandardLocation.PLATFORM_CLASS_PATH);
}
 
Example 12
Source File: ElementStructureTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException {
    if (location != StandardLocation.PLATFORM_CLASS_PATH || kind != Kind.CLASS)
        return null;

    return className2File.get(className);
}
 
Example 13
Source File: Locations.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
BootClassPathLocationHandler() {
    super(StandardLocation.PLATFORM_CLASS_PATH,
            Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
            Option.XBOOTCLASSPATH_PREPEND,
            Option.XBOOTCLASSPATH_APPEND,
            Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
            Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
}
 
Example 14
Source File: Locations.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
BootClassPathLocationHandler() {
    super(StandardLocation.PLATFORM_CLASS_PATH,
            Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
            Option.XBOOTCLASSPATH_PREPEND,
            Option.XBOOTCLASSPATH_APPEND,
            Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
            Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
}
 
Example 15
Source File: Locations.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
BootClassPathLocationHandler() {
    super(StandardLocation.PLATFORM_CLASS_PATH,
            Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
            Option.XBOOTCLASSPATH_PREPEND,
            Option.XBOOTCLASSPATH_APPEND,
            Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
            Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
}
 
Example 16
Source File: JavaCodeScriptEngine.java    From chaosblade-exec-jvm with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasLocation(Location location) {
    return location == StandardLocation.CLASS_PATH || location == StandardLocation.PLATFORM_CLASS_PATH;
}
 
Example 17
Source File: NativeJavaCompiler.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasLocation(Location location) {
    // we don't care about source and other location types - not needed for compilation
    return location == StandardLocation.CLASS_PATH || location == StandardLocation.PLATFORM_CLASS_PATH;
}
 
Example 18
Source File: MemoryBasedJavaFileManager.java    From spring-init with Apache License 2.0 4 votes vote down vote up
@Override
	public Iterable<JavaFileObject> list(Location location, String packageName,
			Set<Kind> kinds, boolean recurse) throws IOException {
		logger.debug("list({},{},{},{})", location, packageName, kinds, recurse);
		String classpath = "";
		Path moduleRootPath = null;
		if (location instanceof JDKModuleLocation && (kinds == null || kinds.contains(Kind.CLASS))) {
			// list(org.springframework.cloud.func[email protected]550a1967,
			//      java.lang,[SOURCE, CLASS, HTML, OTHER],false)
			moduleRootPath = ((JDKModuleLocation)location).getModuleRootPath();
			logger.info("For JDKModuleLocation "+location.toString()+" root path is "+moduleRootPath);
		} else if (location == StandardLocation.PLATFORM_CLASS_PATH
				&& (kinds == null || kinds.contains(Kind.CLASS))) {
			classpath = getPlatformClassPath();
//			if (classpath.length() == 0) {
//			if (hasJrtFsPath()) {
//				classpath = getJrtFsPath();
//			}
//		}
			logger.debug("Creating iterable for boot class path: {}", classpath);
		}
		else if (location == StandardLocation.CLASS_PATH
				&& (kinds == null || kinds.contains(Kind.CLASS))) {
			String javaClassPath = getClassPath();
			if (!resolvedAdditionalDependencies.isEmpty()) {
				for (File resolvedAdditionalDependency : resolvedAdditionalDependencies
						.values()) {
					javaClassPath += File.pathSeparatorChar + resolvedAdditionalDependency
							.toURI().toString().substring("file:".length());
				}
			}
			classpath = javaClassPath;
			logger.debug("Creating iterable for class path: {}", classpath);
		}
		Key k = new Key(location, classpath, packageName, kinds, recurse);
		CloseableFilterableJavaFileObjectIterable resultIterable = iterables.get(k);
		if (resultIterable == null) {
			if (moduleRootPath != null) {
				resultIterable = new IterableJrtModule(compilationInfoCache, moduleRootPath, packageName, recurse);
			} else {
				resultIterable = new IterableClasspath(compilationInfoCache, classpath, packageName, recurse);
			}
			iterables.put(k, resultIterable);
		}
		resultIterable.reset();
		return resultIterable;
	}
 
Example 19
Source File: AsyncJavaSymbolDescriptor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasLocation(Location location) {
    return location == StandardLocation.CLASS_PATH || location == StandardLocation.PLATFORM_CLASS_PATH;
}
 
Example 20
Source File: MemoryBasedJavaFileManager.java    From spring-cloud-function with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<JavaFileObject> list(Location location, String packageName,
		Set<Kind> kinds, boolean recurse) throws IOException {
	logger.debug("list({},{},{},{})", location, packageName, kinds, recurse);
	String classpath = "";
	Path moduleRootPath = null;
	if (location instanceof JDKModuleLocation
			&& (kinds == null || kinds.contains(Kind.CLASS))) {
		// list(org.springframework.cloud.func[email protected]550a1967,
		// java.lang,[SOURCE, CLASS, HTML, OTHER],false)
		moduleRootPath = ((JDKModuleLocation) location).getModuleRootPath();
		logger.debug("For JDKModuleLocation " + location.toString() + " root path is "
				+ moduleRootPath);
	}
	else if (location == StandardLocation.PLATFORM_CLASS_PATH
			&& (kinds == null || kinds.contains(Kind.CLASS))) {
		classpath = getPlatformClassPath();
		// if (classpath.length() == 0) {
		// if (hasJrtFsPath()) {
		// classpath = getJrtFsPath();
		// }
		// }
		logger.debug("Creating iterable for boot class path: {}", classpath);
	}
	else if (location == StandardLocation.CLASS_PATH
			&& (kinds == null || kinds.contains(Kind.CLASS))) {
		String javaClassPath = getClassPath();
		if (!this.resolvedAdditionalDependencies.isEmpty()) {
			for (File resolvedAdditionalDependency : this.resolvedAdditionalDependencies
					.values()) {
				javaClassPath += File.pathSeparatorChar + resolvedAdditionalDependency
						.toURI().toString().substring("file:".length());
			}
		}
		classpath = javaClassPath;
		logger.debug("Creating iterable for class path: {}", classpath);
	}
	Key k = new Key(location, classpath, packageName, kinds, recurse);
	CloseableFilterableJavaFileObjectIterable resultIterable = this.iterables.get(k);
	if (resultIterable == null) {
		if (moduleRootPath != null) {
			resultIterable = new IterableJrtModule(this.compilationInfoCache,
					moduleRootPath, packageName, recurse);
		}
		else {
			resultIterable = new IterableClasspath(this.compilationInfoCache,
					classpath, packageName, recurse);
		}
		this.iterables.put(k, resultIterable);
	}
	resultIterable.reset();
	return resultIterable;
}