Tue, 20 Aug 2013 14:15:45 -0700
7179455: tools/javac/processing/model/testgetallmembers/Main.java fails against JDK 7 and JDK 8
Reviewed-by: jjg
test/tools/javac/processing/model/testgetallmembers/Main.java | file | annotate | diff | comparison | revisions |
1.1 --- a/test/tools/javac/processing/model/testgetallmembers/Main.java Tue Aug 20 12:15:19 2013 -0700 1.2 +++ b/test/tools/javac/processing/model/testgetallmembers/Main.java Tue Aug 20 14:15:45 2013 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -31,7 +31,6 @@ 1.11 1.12 import java.io.File; 1.13 import java.util.*; 1.14 -import javax.lang.model.SourceVersion; 1.15 import javax.lang.model.element.Element; 1.16 import javax.lang.model.element.ElementKind; 1.17 import javax.lang.model.element.PackageElement; 1.18 @@ -60,7 +59,10 @@ 1.19 static Elements elements; 1.20 1.21 public static void main(String[] args) throws Exception { 1.22 - 1.23 + if (haveAltRt()) { 1.24 + System.out.println("Warning: alt-rt.jar detected, test skipped"); 1.25 + return; 1.26 + } 1.27 JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); 1.28 StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); 1.29 fm.setLocation(CLASS_PATH, Collections.<File>emptyList()); 1.30 @@ -123,4 +125,23 @@ 1.31 if (nestedClasses < 3000) 1.32 throw new AssertionError("Too few nested classes in PLATFORM_CLASS_PATH ;-)"); 1.33 } 1.34 + /* 1.35 + * If -XX:+AggressiveOpts has been used to test, the option currently 1.36 + * instructs the VM to prepend alt-rt.jar onto the bootclasspath. This 1.37 + * overrides the default TreeMap implemation in rt.jar causing symbol 1.38 + * resolution problems (caused by inconsistent inner class), although 1.39 + * alt-rt.jar is being eliminated, we have this sanity check to detect this 1.40 + * case and skip the test. 1.41 + */ 1.42 + static boolean haveAltRt() { 1.43 + String bootClassPath = System.getProperty("sun.boot.class.path"); 1.44 + for (String cp : bootClassPath.split(File.pathSeparator)) { 1.45 + if (cp.endsWith("alt-rt.jar")) { 1.46 + System.err.println("Warning: detected alt-rt.jar in " 1.47 + + "sun.boot.class.path"); 1.48 + return true; 1.49 + } 1.50 + } 1.51 + return false; 1.52 + } 1.53 }