7179455: tools/javac/processing/model/testgetallmembers/Main.java fails against JDK 7 and JDK 8
authorksrini
Tue, 20 Aug 2013 14:15:45 -0700
changeset 19509 fb622612d5df
parent 19508 e2cd0ed6c9b0
child 19510 d2afcb89b0e7
7179455: tools/javac/processing/model/testgetallmembers/Main.java fails against JDK 7 and JDK 8 Reviewed-by: jjg
langtools/test/tools/javac/processing/model/testgetallmembers/Main.java
--- a/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java	Tue Aug 20 12:15:19 2013 -0700
+++ b/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java	Tue Aug 20 14:15:45 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
 
 import java.io.File;
 import java.util.*;
-import javax.lang.model.SourceVersion;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.PackageElement;
@@ -60,7 +59,10 @@
     static Elements elements;
 
     public static void main(String[] args) throws Exception {
-
+        if (haveAltRt()) {
+            System.out.println("Warning: alt-rt.jar detected, test skipped");
+            return;
+        }
         JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
         fm.setLocation(CLASS_PATH, Collections.<File>emptyList());
@@ -123,4 +125,23 @@
         if (nestedClasses < 3000)
             throw new AssertionError("Too few nested classes in PLATFORM_CLASS_PATH ;-)");
     }
+    /*
+     * If -XX:+AggressiveOpts has been used to test, the option currently
+     * instructs the VM to prepend alt-rt.jar onto the bootclasspath. This
+     * overrides the default TreeMap implemation in rt.jar causing symbol
+     * resolution problems (caused by inconsistent inner class), although
+     * alt-rt.jar is being eliminated, we have this sanity check to detect this
+     * case and skip the test.
+     */
+    static boolean haveAltRt() {
+        String bootClassPath = System.getProperty("sun.boot.class.path");
+        for (String cp : bootClassPath.split(File.pathSeparator)) {
+            if (cp.endsWith("alt-rt.jar")) {
+                System.err.println("Warning: detected alt-rt.jar in "
+                        + "sun.boot.class.path");
+                return true;
+            }
+        }
+        return false;
+    }
 }