changeset 2372:0f88e3d3d250

7179455: tools/javac/processing/model/testgetallmembers/Main.java fails against JDK 7 and JDK 8 Reviewed-by: jjg
author ksrini
date Tue, 20 Aug 2013 14:15:45 -0700
parents 58da1296c6b3
children a76dc1b4c299
files test/tools/javac/processing/model/testgetallmembers/Main.java
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/tools/javac/processing/model/testgetallmembers/Main.java	Tue Aug 20 12:15:19 2013 -0700
+++ b/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;
+    }
 }