test/java/lang/reflect/Generics/Probe.java

Print this page
rev 811 : 6704655: Test test/java/lang/reflect/Generics/Probe.java fails under OpenJDK
Reviewed-by: ksrini

@@ -21,21 +21,23 @@
  * have any questions.
  */
 
 /*
  * @test
- * @bug 5003916
+ * @bug 5003916 6704655
  * @summary Testing parsing of signatures attributes of nested classes
  * @author Joseph D. Darcy
  * @compile -source 1.5 Probe.java
  * @run main Probe
  */
 
 import java.lang.reflect.*;
 import java.lang.annotation.*;
+import java.util.*;
+import static java.util.Arrays.*;
 
-@Classes({
+@Classes(value={
         "java.util.concurrent.FutureTask",
         "java.util.concurrent.ConcurrentHashMap$EntryIterator",
         "java.util.concurrent.ConcurrentHashMap$KeyIterator",
         "java.util.concurrent.ConcurrentHashMap$ValueIterator",
         "java.util.AbstractList$ListItr",

@@ -54,22 +56,32 @@
         "java.util.HashMap$EntryIterator",
         "java.util.HashMap$KeyIterator",
         "java.util.HashMap$ValueIterator",
         "java.util.LinkedHashMap$EntryIterator",
         "java.util.LinkedHashMap$KeyIterator",
-        "java.util.LinkedHashMap$ValueIterator",
+        "java.util.LinkedHashMap$ValueIterator"
+        },
+        sunClasses={
         "javax.crypto.SunJCE_c",
         "javax.crypto.SunJCE_e",
         "javax.crypto.SunJCE_f",
         "javax.crypto.SunJCE_j",
         "javax.crypto.SunJCE_k",
         "javax.crypto.SunJCE_l"
         })
 public class Probe {
     public static void main (String[] args) throws Throwable {
-        String [] names = (Probe.class).getAnnotation(Classes.class).value();
+        Classes classesAnnotation = (Probe.class).getAnnotation(Classes.class);
+        List<String> names =
+            new ArrayList<String>(asList(classesAnnotation.value()));
 
+        if (System.getProperty("java.runtime.name").startsWith("Java(TM)")) {
+            // Sun production JDK; test crypto classes too
+            for(String name: classesAnnotation.sunClasses())
+                names.add(name);
+        }
+
         int errs = 0;
         for(String name: names) {
             System.out.println("\nCLASS " + name);
             Class c = Class.forName(name, false, null);
             errs += probe(c);

@@ -138,6 +150,7 @@
 }
 
 @Retention(RetentionPolicy.RUNTIME)
 @interface Classes {
     String [] value(); // list of classes to probe
+    String [] sunClasses(); // list of Sun-production JDK specific classes to probe
 }