author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 29053 | 5c1f1d6b40f6 |
permissions | -rw-r--r-- |
29053
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29053
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
29053
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
4 |
* |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
8 |
* |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
13 |
* accompanied this code). |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
14 |
* |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
18 |
* |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
21 |
* questions. |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
22 |
*/ |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
23 |
|
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
24 |
/** |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
25 |
* @test |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
26 |
* @bug 8067445 |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
27 |
* @summary Verify that file.Locations analyze sun.boot.class.path for BCP prepends/appends |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
28 |
* @library /tools/lib |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29053
diff
changeset
|
29 |
* @modules jdk.compiler/com.sun.tools.javac.api |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29053
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.file |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29053
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.main |
29053
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
32 |
*/ |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
33 |
|
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
34 |
import java.io.IOException; |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
35 |
import java.util.EnumSet; |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
36 |
import javax.tools.JavaCompiler; |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
37 |
import javax.tools.JavaFileManager; |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
38 |
import javax.tools.JavaFileObject; |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
39 |
import javax.tools.JavaFileObject.Kind; |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
40 |
import javax.tools.StandardLocation; |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
41 |
import javax.tools.ToolProvider; |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
42 |
|
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
43 |
public class BootClassPathPrepend { |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
44 |
public static void main(String... args) throws IOException { |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
45 |
if (args.length == 0) { |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
46 |
new BootClassPathPrepend().reRun(); |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
47 |
} else { |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
48 |
new BootClassPathPrepend().run(); |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
49 |
} |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
50 |
} |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
51 |
|
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
52 |
void reRun() { |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
53 |
String testClasses = System.getProperty("test.classes"); |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
54 |
ToolBox tb = new ToolBox(); |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
55 |
tb.new JavaTask().vmOptions("-Xbootclasspath/p:" + testClasses) |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
56 |
.classArgs("real-run") |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
57 |
.className("BootClassPathPrepend") |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
58 |
.run() |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
59 |
.writeAll(); |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
60 |
} |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
61 |
|
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
62 |
EnumSet<Kind> classKind = EnumSet.of(JavaFileObject.Kind.CLASS); |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
63 |
|
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
64 |
void run() throws IOException { |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
65 |
JavaCompiler toolProvider = ToolProvider.getSystemJavaCompiler(); |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
66 |
try (JavaFileManager fm = toolProvider.getStandardFileManager(null, null, null)) { |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
67 |
Iterable<JavaFileObject> files = |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
68 |
fm.list(StandardLocation.PLATFORM_CLASS_PATH, "", classKind, false); |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
69 |
for (JavaFileObject fo : files) { |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
70 |
if (fo.isNameCompatible("BootClassPathPrepend", JavaFileObject.Kind.CLASS)) { |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
71 |
System.err.println("Found BootClassPathPrepend on bootclasspath"); |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
72 |
return ;//found |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
73 |
} |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
74 |
} |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
75 |
|
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
76 |
throw new AssertionError("Cannot find class that was prepended on BCP"); |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
77 |
} |
5c1f1d6b40f6
8067445: New modular image-based file manager skips boot classes
jlahoda
parents:
diff
changeset
|
78 |
} |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
29053
diff
changeset
|
79 |
} |