1 /* |
1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
52 /** |
52 /** |
53 * Main entry point. |
53 * Main entry point. |
54 */ |
54 */ |
55 boolean run(String... args) throws Exception { |
55 boolean run(String... args) throws Exception { |
56 JavaCompiler c = ToolProvider.getSystemJavaCompiler(); |
56 JavaCompiler c = ToolProvider.getSystemJavaCompiler(); |
57 JavaFileManager fm = c.getStandardFileManager(null, null, null); |
57 try (JavaFileManager fm = c.getStandardFileManager(null, null, null)) { |
58 JavaFileManager.Location javacLoc = findJavacLocation(fm); |
58 JavaFileManager.Location javacLoc = findJavacLocation(fm); |
59 String[] pkgs = { |
59 String[] pkgs = { |
60 "javax.annotation.processing", |
60 "javax.annotation.processing", |
61 "javax.lang.model", |
61 "javax.lang.model", |
62 "javax.tools", |
62 "javax.tools", |
63 "com.sun.source", |
63 "com.sun.source", |
64 "com.sun.tools.classfile", |
64 "com.sun.tools.classfile", |
65 "com.sun.tools.doclet", |
65 "com.sun.tools.doclet", |
66 "com.sun.tools.doclint", |
66 "com.sun.tools.doclint", |
67 "com.sun.tools.javac", |
67 "com.sun.tools.javac", |
68 "com.sun.tools.javadoc", |
68 "com.sun.tools.javadoc", |
69 "com.sun.tools.javah", |
69 "com.sun.tools.javah", |
70 "com.sun.tools.javap", |
70 "com.sun.tools.javap", |
71 "com.sun.tools.jdeps", |
71 "com.sun.tools.jdeps", |
72 "com.sun.tools.sjavac" |
72 "com.sun.tools.sjavac" |
73 }; |
73 }; |
74 for (String pkg: pkgs) { |
74 for (String pkg: pkgs) { |
75 for (JavaFileObject fo: fm.list(javacLoc, |
75 for (JavaFileObject fo: fm.list(javacLoc, |
76 pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) { |
76 pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) { |
77 scan(fo); |
77 scan(fo); |
|
78 } |
78 } |
79 } |
|
80 |
|
81 return (errors == 0); |
79 } |
82 } |
80 |
|
81 return (errors == 0); |
|
82 } |
83 } |
83 |
84 |
84 // depending on how the test is run, javac may be on bootclasspath or classpath |
85 // depending on how the test is run, javac may be on bootclasspath or classpath |
85 JavaFileManager.Location findJavacLocation(JavaFileManager fm) { |
86 JavaFileManager.Location findJavacLocation(JavaFileManager fm) { |
86 JavaFileManager.Location[] locns = |
87 JavaFileManager.Location[] locns = |