1 /* |
1 /* |
2 * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2006, 2013, 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. |
29 * @run main/othervm -Xmx256m Main |
29 * @run main/othervm -Xmx256m Main |
30 */ |
30 */ |
31 |
31 |
32 import java.io.File; |
32 import java.io.File; |
33 import java.util.*; |
33 import java.util.*; |
34 import javax.lang.model.SourceVersion; |
|
35 import javax.lang.model.element.Element; |
34 import javax.lang.model.element.Element; |
36 import javax.lang.model.element.ElementKind; |
35 import javax.lang.model.element.ElementKind; |
37 import javax.lang.model.element.PackageElement; |
36 import javax.lang.model.element.PackageElement; |
38 import javax.lang.model.element.TypeElement; |
37 import javax.lang.model.element.TypeElement; |
39 import javax.lang.model.util.Elements; |
38 import javax.lang.model.util.Elements; |
58 static JavaCompiler tool; |
57 static JavaCompiler tool; |
59 static JavacTask javac; |
58 static JavacTask javac; |
60 static Elements elements; |
59 static Elements elements; |
61 |
60 |
62 public static void main(String[] args) throws Exception { |
61 public static void main(String[] args) throws Exception { |
63 |
62 if (haveAltRt()) { |
|
63 System.out.println("Warning: alt-rt.jar detected, test skipped"); |
|
64 return; |
|
65 } |
64 JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); |
66 JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); |
65 StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); |
67 StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); |
66 fm.setLocation(CLASS_PATH, Collections.<File>emptyList()); |
68 fm.setLocation(CLASS_PATH, Collections.<File>emptyList()); |
67 JavacTask javac = (JavacTask)tool.getTask(null, fm, null, null, null, null); |
69 JavacTask javac = (JavacTask)tool.getTask(null, fm, null, null, null, null); |
68 Elements elements = javac.getElements(); |
70 Elements elements = javac.getElements(); |
121 if (packages.size() < 530) |
123 if (packages.size() < 530) |
122 throw new AssertionError("Too few packages in PLATFORM_CLASS_PATH ;-)"); |
124 throw new AssertionError("Too few packages in PLATFORM_CLASS_PATH ;-)"); |
123 if (nestedClasses < 3000) |
125 if (nestedClasses < 3000) |
124 throw new AssertionError("Too few nested classes in PLATFORM_CLASS_PATH ;-)"); |
126 throw new AssertionError("Too few nested classes in PLATFORM_CLASS_PATH ;-)"); |
125 } |
127 } |
|
128 /* |
|
129 * If -XX:+AggressiveOpts has been used to test, the option currently |
|
130 * instructs the VM to prepend alt-rt.jar onto the bootclasspath. This |
|
131 * overrides the default TreeMap implemation in rt.jar causing symbol |
|
132 * resolution problems (caused by inconsistent inner class), although |
|
133 * alt-rt.jar is being eliminated, we have this sanity check to detect this |
|
134 * case and skip the test. |
|
135 */ |
|
136 static boolean haveAltRt() { |
|
137 String bootClassPath = System.getProperty("sun.boot.class.path"); |
|
138 for (String cp : bootClassPath.split(File.pathSeparator)) { |
|
139 if (cp.endsWith("alt-rt.jar")) { |
|
140 System.err.println("Warning: detected alt-rt.jar in " |
|
141 + "sun.boot.class.path"); |
|
142 return true; |
|
143 } |
|
144 } |
|
145 return false; |
|
146 } |
126 } |
147 } |