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

(reflect) GenericSignatureFormatError When signature includes nested inner classes

XMLWordPrintable

      Since JDK7b143 the following code throws GenericSignatureFormatError:

      ---------------------------------------------------------------------------
          Class c = Class.forName("javax.swing.JComboBox$AccessibleJComboBox");
          System.out.println("Class = " + c);
          for ( Field f : c.getDeclaredFields()) {
              System.out.println(" [FIELD] " + f.getName());
              System.out.println(" [TYPE] " + f.getType());
              System.out.println(" [GENERICTYPE] " + f.getGenericType());
          }
      ---------------------------------------------------------------------------

      The output is:

      ---------------------------------------------------------------------------
      Class = class javax.swing.JComboBox$AccessibleJComboBox
       [FIELD] popupList
        [TYPE] class javax.swing.JList
        [GENERICTYPE] class javax.swing.JList
       [FIELD] previousSelectedAccessible
        [TYPE] interface javax.accessibility.Accessible
        [GENERICTYPE] interface javax.accessibility.Accessible
       [FIELD] editorAccessibleContext
        [TYPE] class javax.swing.JComboBox$AccessibleJComboBox$EditorAccessibleContext
      Exception in thread "main" java.lang.reflect.GenericSignatureFormatError
              at sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:121)
              at sun.reflect.generics.parser.SignatureParser.parseSimpleClassTypeSignature(SignatureParser.java:280)
              at sun.reflect.generics.parser.SignatureParser.parseClassTypeSignatureSuffix(SignatureParser.java:288)
              at sun.reflect.generics.parser.SignatureParser.parseClassTypeSignature(SignatureParser.java:262)
              at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:246)
              at sun.reflect.generics.parser.SignatureParser.parseTypeSignature(SignatureParser.java:377)
              at sun.reflect.generics.parser.SignatureParser.parseTypeSig(SignatureParser.java:175)
              at sun.reflect.generics.repository.FieldRepository.parse(FieldRepository.java:52)
              at sun.reflect.generics.repository.FieldRepository.parse(FieldRepository.java:42)
              at sun.reflect.generics.repository.AbstractRepository.<init>(AbstractRepository.java:74)
              at sun.reflect.generics.repository.FieldRepository.<init>(FieldRepository.java:48)
              at sun.reflect.generics.repository.FieldRepository.make(FieldRepository.java:66)
              at java.lang.reflect.Field.getGenericInfo(Field.java:98)
              at java.lang.reflect.Field.getGenericType(Field.java:236)
              at testapp.reflect.GenericSignatureFormatError.main(GenericSignatureFormatError.java:21)
      ---------------------------------------------------------------------------

      in JDK7b140, for instance, the code prints:
      ---------------------------------------------------------------------------
      Class = class javax.swing.JComboBox$AccessibleJComboBox
       [FIELD] popupList
        [TYPE] class javax.swing.JList
        [GENERICTYPE] class javax.swing.JList
       [FIELD] previousSelectedAccessible
        [TYPE] interface javax.accessibility.Accessible
        [GENERICTYPE] interface javax.accessibility.Accessible
       [FIELD] editorAccessibleContext
        [TYPE] class javax.swing.JComboBox$AccessibleJComboBox$EditorAccessibleContext
        [GENERICTYPE] class javax.swing.JComboBox$AccessibleJComboBox$EditorAccessibleContext
       [FIELD] this$0
        [TYPE] class javax.swing.JComboBox
        [GENERICTYPE] class javax.swing.JComboBox
      ---------------------------------------------------------------------------

            darcy Joe Darcy
            ashusher Alexander Shusherov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: