提交 205f164d 编写于 作者: J jjg

6968434: test CheckResourceKeys fails on control builds

Reviewed-by: darcy
上级 6930343f
......@@ -294,6 +294,7 @@ public class CheckResourceKeys {
Set<String> results = new TreeSet<String>();
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
JavaFileManager fm = c.getStandardFileManager(null, null, null);
JavaFileManager.Location javacLoc = findJavacLocation(fm);
String[] pkgs = {
"javax.annotation.processing",
"javax.lang.model",
......@@ -302,7 +303,7 @@ public class CheckResourceKeys {
"com.sun.tools.javac"
};
for (String pkg: pkgs) {
for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
for (JavaFileObject fo: fm.list(javacLoc,
pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
String name = fo.getName();
// ignore resource files, and files which are not really part of javac
......@@ -316,6 +317,23 @@ public class CheckResourceKeys {
return results;
}
// depending on how the test is run, javac may be on bootclasspath or classpath
JavaFileManager.Location findJavacLocation(JavaFileManager fm) {
JavaFileManager.Location[] locns =
{ StandardLocation.PLATFORM_CLASS_PATH, StandardLocation.CLASS_PATH };
try {
for (JavaFileManager.Location l: locns) {
JavaFileObject fo = fm.getJavaFileForInput(l,
"com.sun.tools.javac.Main", JavaFileObject.Kind.CLASS);
if (fo != null)
return l;
}
} catch (IOException e) {
throw new Error(e);
}
throw new IllegalStateException("Cannot find javac");
}
/**
* Get the set of strings from a class file.
* Only strings that look like they might be a resource key are returned.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册