Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5003916

(reflect) 24 classes from java package cause GenericSignatureFormatError

    XMLWordPrintable

Details

    • b48
    • generic
    • generic
    • Verified

    Description



      Name: siR10004 Date: 02/26/2004



      The following classes -

      -------------------------------------------------------------
      java.util.concurrent.FutureTask
      java.util.concurrent.ConcurrentHashMap$EntryIterator
      java.util.concurrent.ConcurrentHashMap$KeyIterator
      java.util.concurrent.ConcurrentHashMap$ValueIterator
      java.util.AbstractList$ListItr
      java.util.EnumMap$EntryIterator
      java.util.EnumMap$KeyIterator
      java.util.EnumMap$ValueIterator
      java.util.IdentityHashMap$EntryIterator
      java.util.IdentityHashMap$KeyIterator
      java.util.IdentityHashMap$ValueIterator
      java.util.WeakHashMap$EntryIterator
      java.util.WeakHashMap$KeyIterator
      java.util.WeakHashMap$ValueIterator
      java.util.TreeMap$EntryIterator
      java.util.TreeMap$KeyIterator
      java.util.TreeMap$SubMapEntryIterator
      java.util.TreeMap$ValueIterator
      java.util.HashMap$EntryIterator
      java.util.HashMap$KeyIterator
      java.util.HashMap$ValueIterator
      java.util.LinkedHashMap$EntryIterator
      java.util.LinkedHashMap$KeyIterator
      java.util.LinkedHashMap$ValueIterator
      -------------------------------------------------------------

      cause 'java.lang.reflect.GenericSignatureFormatError' thrown
      when calling some of reflection methods to get generic types.

      The following program can be used to reproduce the bug
      -------------------------------------------------------------
      import java.lang.reflect.*;

      public class Probe {
          public static void main (String[] args) throws Throwable
          {
              String name = args[0];
              System.out.println("\nCLASS " + name);
              Class c = Class.forName(name, false, null);
              int errs = probe(c);
              System.out.println(errs == 0 ? " ok" : " errors:" + errs);
          }
          
          static int probe (Class c)
          {
           int errs = 0;
          
              try {
                  c.getTypeParameters();
                  c.getGenericSuperclass();
                  c.getGenericInterfaces();
              }
              catch (Throwable t) {
                  errs++;
                  System.err.println(t);
                  //t.printStackTrace();
              }
              
              Field[] fields = c.getDeclaredFields();
              if (fields != null)
                  for (int i = 0; i < fields.length; i++) {
                      try {
                          fields[i].getGenericType();
                      }
                      catch (Throwable t) {
                          errs++;
                          System.err.println("FIELD " + fields[i]);
                          System.err.println(t);
                          //t.printStackTrace();
                      }
                  }
              
              Method[] methods = c.getDeclaredMethods();
              if (methods != null)
                  for (int i = 0; i < methods.length; i++) {
                      try {
                          methods[i].getTypeParameters();
                          methods[i].getGenericReturnType();
                          methods[i].getGenericParameterTypes();
                          methods[i].getGenericExceptionTypes();
                      }
                      catch (Throwable t) {
                          errs++;
                          System.err.println("METHOD " + methods[i]);
                          System.err.println(t);
                          //t.printStackTrace();
                      }
                  }
                  
              Constructor[] ctors = c.getDeclaredConstructors();
              if (ctors != null)
                  for (int i = 0; i < ctors.length; i++) {
                      try {
                          ctors[i].getTypeParameters();
                          ctors[i].getGenericParameterTypes();
                          ctors[i].getGenericExceptionTypes();
                      }
                      catch (Throwable t) {
                          errs++;
                          System.err.println("CONSTRUCTOR " + ctors[i]);
                          System.err.println(t);
                          //t.printStackTrace();
                      }
                  }
                  
              return errs;
          }
      }
      -------------------------------------------------------------

      This bug causes failure of JCK signature test on b40.
      Not reproducible on b39.

      It seems that root of the problem is in invalid 'Signature' attributes.
      For example, field
        java.util.concurrent.FutureTask.sync
      has the following attribute
        Ljava/util/concurrent/FutureTask<TV;>.Sync;
      (note that '.Sync' violates the signature attribute syntax).

      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              darcy Joe Darcy
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: