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

Print this page
rev 5551 : 8004928: TEST_BUG: Reduce dependence of CoreLib tests from the AWT subsystem
Summary: the tests were refactored to drop AWT dependence where it was possible.
Reviewed-by: alanb, mchung


   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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 5003916 6704655 6873951 6476261
  27  * @summary Testing parsing of signatures attributes of nested classes
  28  * @author Joseph D. Darcy
  29  */
  30 
  31 import java.lang.reflect.*;
  32 import java.lang.annotation.*;
  33 import java.util.*;
  34 import static java.util.Arrays.*;
  35 
  36 @Classes({"java.util.concurrent.FutureTask",
  37           "java.util.concurrent.ConcurrentHashMap$EntryIterator",
  38           "java.util.concurrent.ConcurrentHashMap$KeyIterator",
  39           "java.util.concurrent.ConcurrentHashMap$ValueIterator",
  40           "java.util.AbstractList$ListItr",
  41           "java.util.EnumMap$EntryIterator",
  42           "java.util.EnumMap$KeyIterator",
  43           "java.util.EnumMap$ValueIterator",
  44           "java.util.IdentityHashMap$EntryIterator",
  45           "java.util.IdentityHashMap$KeyIterator",
  46           "java.util.IdentityHashMap$ValueIterator",
  47           "java.util.WeakHashMap$EntryIterator",
  48           "java.util.WeakHashMap$KeyIterator",
  49           "java.util.WeakHashMap$ValueIterator",
  50           "java.util.HashMap$EntryIterator",
  51           "java.util.HashMap$KeyIterator",
  52           "java.util.HashMap$ValueIterator",
  53           "java.util.LinkedHashMap$EntryIterator",
  54           "java.util.LinkedHashMap$KeyIterator",
  55           "java.util.LinkedHashMap$ValueIterator",
  56           "javax.swing.JComboBox$AccessibleJComboBox"})
  57 public class Probe {
  58     public static void main (String... args) throws Throwable {
  59         Classes classesAnnotation = (Probe.class).getAnnotation(Classes.class);
  60         List<String> names = new ArrayList<>(asList(classesAnnotation.value()));
  61 
  62         int errs = 0;
  63         for(String name: names) {
  64             System.out.println("\nCLASS " + name);
  65             Class c = Class.forName(name, false, null);
  66             errs += probe(c);
  67             System.out.println(errs == 0 ? "  ok" : "  ERRORS:" + errs);
  68         }
  69 
  70         if (errs > 0 )
  71             throw new RuntimeException("Errors during probing.");
  72     }
  73 
  74     static int probe (Class c) {
  75         int errs = 0;
  76 




   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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 5003916 6704655 6873951 6476261 8004928
  27  * @summary Testing parsing of signatures attributes of nested classes
  28  * @author Joseph D. Darcy
  29  */
  30 
  31 import java.lang.reflect.*;
  32 import java.lang.annotation.*;
  33 import java.util.*;
  34 import static java.util.Arrays.*;
  35 
  36 @Classes({"java.util.concurrent.FutureTask",
  37           "java.util.concurrent.ConcurrentHashMap$EntryIterator",
  38           "java.util.concurrent.ConcurrentHashMap$KeyIterator",
  39           "java.util.concurrent.ConcurrentHashMap$ValueIterator",
  40           "java.util.AbstractList$ListItr",
  41           "java.util.EnumMap$EntryIterator",
  42           "java.util.EnumMap$KeyIterator",
  43           "java.util.EnumMap$ValueIterator",
  44           "java.util.IdentityHashMap$EntryIterator",
  45           "java.util.IdentityHashMap$KeyIterator",
  46           "java.util.IdentityHashMap$ValueIterator",
  47           "java.util.WeakHashMap$EntryIterator",
  48           "java.util.WeakHashMap$KeyIterator",
  49           "java.util.WeakHashMap$ValueIterator",
  50           "java.util.HashMap$EntryIterator",
  51           "java.util.HashMap$KeyIterator",
  52           "java.util.HashMap$ValueIterator",
  53           "java.util.LinkedHashMap$EntryIterator",
  54           "java.util.LinkedHashMap$KeyIterator",
  55           "java.util.LinkedHashMap$ValueIterator"})

  56 public class Probe {
  57     public static void main (String... args) throws Throwable {
  58         Classes classesAnnotation = (Probe.class).getAnnotation(Classes.class);
  59         List<String> names = new ArrayList<>(asList(classesAnnotation.value()));
  60 
  61         int errs = 0;
  62         for(String name: names) {
  63             System.out.println("\nCLASS " + name);
  64             Class c = Class.forName(name, false, null);
  65             errs += probe(c);
  66             System.out.println(errs == 0 ? "  ok" : "  ERRORS:" + errs);
  67         }
  68 
  69         if (errs > 0 )
  70             throw new RuntimeException("Errors during probing.");
  71     }
  72 
  73     static int probe (Class c) {
  74         int errs = 0;
  75