6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24 /*
25 * @test
26 * @bug 5003916
27 * @summary Testing parsing of signatures attributes of nested classes
28 * @author Joseph D. Darcy
29 * @compile -source 1.5 Probe.java
30 * @run main Probe
31 */
32
33 import java.lang.reflect.*;
34 import java.lang.annotation.*;
35
36 @Classes({
37 "java.util.concurrent.FutureTask",
38 "java.util.concurrent.ConcurrentHashMap$EntryIterator",
39 "java.util.concurrent.ConcurrentHashMap$KeyIterator",
40 "java.util.concurrent.ConcurrentHashMap$ValueIterator",
41 "java.util.AbstractList$ListItr",
42 "java.util.EnumMap$EntryIterator",
43 "java.util.EnumMap$KeyIterator",
44 "java.util.EnumMap$ValueIterator",
45 "java.util.IdentityHashMap$EntryIterator",
46 "java.util.IdentityHashMap$KeyIterator",
47 "java.util.IdentityHashMap$ValueIterator",
48 "java.util.WeakHashMap$EntryIterator",
49 "java.util.WeakHashMap$KeyIterator",
50 "java.util.WeakHashMap$ValueIterator",
51 "java.util.TreeMap$EntryIterator",
52 "java.util.TreeMap$KeyIterator",
53 "java.util.TreeMap$ValueIterator",
54 "java.util.HashMap$EntryIterator",
55 "java.util.HashMap$KeyIterator",
56 "java.util.HashMap$ValueIterator",
57 "java.util.LinkedHashMap$EntryIterator",
58 "java.util.LinkedHashMap$KeyIterator",
59 "java.util.LinkedHashMap$ValueIterator",
60 "javax.crypto.SunJCE_c",
61 "javax.crypto.SunJCE_e",
62 "javax.crypto.SunJCE_f",
63 "javax.crypto.SunJCE_j",
64 "javax.crypto.SunJCE_k",
65 "javax.crypto.SunJCE_l"
66 })
67 public class Probe {
68 public static void main (String[] args) throws Throwable {
69 String [] names = (Probe.class).getAnnotation(Classes.class).value();
70
71 int errs = 0;
72 for(String name: names) {
73 System.out.println("\nCLASS " + name);
74 Class c = Class.forName(name, false, null);
75 errs += probe(c);
76 System.out.println(errs == 0 ? " ok" : " ERRORS:" + errs);
77 }
78
79 if (errs > 0 )
80 throw new RuntimeException("Errors during probing.");
81 }
82
83 static int probe (Class c) {
84 int errs = 0;
85
86 try {
87 c.getTypeParameters();
88 c.getGenericSuperclass();
89 c.getGenericInterfaces();
90 } catch (Throwable t) {
123 if (ctors != null)
124 for(Constructor ctor: ctors) {
125 try {
126 ctor.getTypeParameters();
127 ctor.getGenericParameterTypes();
128 ctor.getGenericExceptionTypes();
129 } catch (Throwable t) {
130 errs++;
131 System.err.println("CONSTRUCTOR " + ctor);
132 System.err.println(t);
133 }
134 }
135
136 return errs;
137 }
138 }
139
140 @Retention(RetentionPolicy.RUNTIME)
141 @interface Classes {
142 String [] value(); // list of classes to probe
143 }
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24 /*
25 * @test
26 * @bug 5003916 6704655
27 * @summary Testing parsing of signatures attributes of nested classes
28 * @author Joseph D. Darcy
29 * @compile -source 1.5 Probe.java
30 * @run main Probe
31 */
32
33 import java.lang.reflect.*;
34 import java.lang.annotation.*;
35 import java.util.*;
36 import static java.util.Arrays.*;
37
38 @Classes(value={
39 "java.util.concurrent.FutureTask",
40 "java.util.concurrent.ConcurrentHashMap$EntryIterator",
41 "java.util.concurrent.ConcurrentHashMap$KeyIterator",
42 "java.util.concurrent.ConcurrentHashMap$ValueIterator",
43 "java.util.AbstractList$ListItr",
44 "java.util.EnumMap$EntryIterator",
45 "java.util.EnumMap$KeyIterator",
46 "java.util.EnumMap$ValueIterator",
47 "java.util.IdentityHashMap$EntryIterator",
48 "java.util.IdentityHashMap$KeyIterator",
49 "java.util.IdentityHashMap$ValueIterator",
50 "java.util.WeakHashMap$EntryIterator",
51 "java.util.WeakHashMap$KeyIterator",
52 "java.util.WeakHashMap$ValueIterator",
53 "java.util.TreeMap$EntryIterator",
54 "java.util.TreeMap$KeyIterator",
55 "java.util.TreeMap$ValueIterator",
56 "java.util.HashMap$EntryIterator",
57 "java.util.HashMap$KeyIterator",
58 "java.util.HashMap$ValueIterator",
59 "java.util.LinkedHashMap$EntryIterator",
60 "java.util.LinkedHashMap$KeyIterator",
61 "java.util.LinkedHashMap$ValueIterator"
62 },
63 sunClasses={
64 "javax.crypto.SunJCE_c",
65 "javax.crypto.SunJCE_e",
66 "javax.crypto.SunJCE_f",
67 "javax.crypto.SunJCE_j",
68 "javax.crypto.SunJCE_k",
69 "javax.crypto.SunJCE_l"
70 })
71 public class Probe {
72 public static void main (String[] args) throws Throwable {
73 Classes classesAnnotation = (Probe.class).getAnnotation(Classes.class);
74 List<String> names =
75 new ArrayList<String>(asList(classesAnnotation.value()));
76
77 if (System.getProperty("java.runtime.name").startsWith("Java(TM)")) {
78 // Sun production JDK; test crypto classes too
79 for(String name: classesAnnotation.sunClasses())
80 names.add(name);
81 }
82
83 int errs = 0;
84 for(String name: names) {
85 System.out.println("\nCLASS " + name);
86 Class c = Class.forName(name, false, null);
87 errs += probe(c);
88 System.out.println(errs == 0 ? " ok" : " ERRORS:" + errs);
89 }
90
91 if (errs > 0 )
92 throw new RuntimeException("Errors during probing.");
93 }
94
95 static int probe (Class c) {
96 int errs = 0;
97
98 try {
99 c.getTypeParameters();
100 c.getGenericSuperclass();
101 c.getGenericInterfaces();
102 } catch (Throwable t) {
135 if (ctors != null)
136 for(Constructor ctor: ctors) {
137 try {
138 ctor.getTypeParameters();
139 ctor.getGenericParameterTypes();
140 ctor.getGenericExceptionTypes();
141 } catch (Throwable t) {
142 errs++;
143 System.err.println("CONSTRUCTOR " + ctor);
144 System.err.println(t);
145 }
146 }
147
148 return errs;
149 }
150 }
151
152 @Retention(RetentionPolicy.RUNTIME)
153 @interface Classes {
154 String [] value(); // list of classes to probe
155 String [] sunClasses(); // list of Sun-production JDK specific classes to probe
156 }
|