0N/A/*
4375N/A * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
4375N/A * @bug 5003916 6704655 6873951 6476261
0N/A * @summary Testing parsing of signatures attributes of nested classes
0N/A * @author Joseph D. Darcy
0N/A */
0N/A
0N/Aimport java.lang.reflect.*;
0N/Aimport java.lang.annotation.*;
842N/Aimport java.util.*;
842N/Aimport static java.util.Arrays.*;
0N/A
1606N/A@Classes({"java.util.concurrent.FutureTask",
1606N/A "java.util.concurrent.ConcurrentHashMap$EntryIterator",
1606N/A "java.util.concurrent.ConcurrentHashMap$KeyIterator",
1606N/A "java.util.concurrent.ConcurrentHashMap$ValueIterator",
1606N/A "java.util.AbstractList$ListItr",
4375N/A "java.util.EnumMap$EntryIterator",
4375N/A "java.util.EnumMap$KeyIterator",
4375N/A "java.util.EnumMap$ValueIterator",
4375N/A "java.util.IdentityHashMap$EntryIterator",
4375N/A "java.util.IdentityHashMap$KeyIterator",
4375N/A "java.util.IdentityHashMap$ValueIterator",
1606N/A "java.util.WeakHashMap$EntryIterator",
1606N/A "java.util.WeakHashMap$KeyIterator",
1606N/A "java.util.WeakHashMap$ValueIterator",
1606N/A "java.util.HashMap$EntryIterator",
1606N/A "java.util.HashMap$KeyIterator",
1606N/A "java.util.HashMap$ValueIterator",
1606N/A "java.util.LinkedHashMap$EntryIterator",
1606N/A "java.util.LinkedHashMap$KeyIterator",
4375N/A "java.util.LinkedHashMap$ValueIterator",
4375N/A "javax.swing.JComboBox$AccessibleJComboBox"})
0N/Apublic class Probe {
1606N/A public static void main (String... args) throws Throwable {
842N/A Classes classesAnnotation = (Probe.class).getAnnotation(Classes.class);
4375N/A List<String> names = new ArrayList<>(asList(classesAnnotation.value()));
842N/A
0N/A int errs = 0;
0N/A for(String name: names) {
0N/A System.out.println("\nCLASS " + name);
0N/A Class c = Class.forName(name, false, null);
0N/A errs += probe(c);
0N/A System.out.println(errs == 0 ? " ok" : " ERRORS:" + errs);
0N/A }
0N/A
0N/A if (errs > 0 )
0N/A throw new RuntimeException("Errors during probing.");
0N/A }
0N/A
0N/A static int probe (Class c) {
0N/A int errs = 0;
0N/A
0N/A try {
0N/A c.getTypeParameters();
0N/A c.getGenericSuperclass();
0N/A c.getGenericInterfaces();
0N/A } catch (Throwable t) {
0N/A errs++;
0N/A System.err.println(t);
0N/A }
0N/A
0N/A Field[] fields = c.getDeclaredFields();
0N/A if (fields != null)
0N/A for(Field field: fields) {
0N/A try {
0N/A field.getGenericType();
0N/A } catch (Throwable t) {
0N/A errs++;
0N/A System.err.println("FIELD " + field);
0N/A System.err.println(t);
0N/A }
0N/A }
0N/A
0N/A Method[] methods = c.getDeclaredMethods();
0N/A if (methods != null)
0N/A for(Method method: methods) {
0N/A try {
0N/A method.getTypeParameters();
0N/A method.getGenericReturnType();
0N/A method.getGenericParameterTypes();
0N/A method.getGenericExceptionTypes();
0N/A } catch (Throwable t) {
0N/A errs++;
0N/A System.err.println("METHOD " + method);
0N/A System.err.println(t);
0N/A }
0N/A }
0N/A
0N/A Constructor[] ctors = c.getDeclaredConstructors();
0N/A if (ctors != null)
0N/A for(Constructor ctor: ctors) {
0N/A try {
0N/A ctor.getTypeParameters();
0N/A ctor.getGenericParameterTypes();
0N/A ctor.getGenericExceptionTypes();
0N/A } catch (Throwable t) {
0N/A errs++;
0N/A System.err.println("CONSTRUCTOR " + ctor);
0N/A System.err.println(t);
0N/A }
0N/A }
0N/A
0N/A return errs;
0N/A }
0N/A}
0N/A
0N/A@Retention(RetentionPolicy.RUNTIME)
0N/A@interface Classes {
0N/A String [] value(); // list of classes to probe
0N/A}