JDK-6470192 : (reflect) Field.getGenericType() throws GenericSignatureFormatError
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 5.0,6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-09-13
  • Updated: 2012-09-28
  • Resolved: 2011-06-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
class GenericFailure<T>
{
    class Nested
    {
        class Sub {}
    }
    Nested.Sub fails;
}


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
write a main with:

        Field f = GenericFailure.class.getDeclaredField("fails");
        Type t = f.getGenericType();





EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
get the generic type of the member field "fails" from class GenericFailure

ACTUAL -
the second line throws an "GenericSignatureFormatError"

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.reflect.GenericSignatureFormatError
        at sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:103)
        at sun.reflect.generics.parser.SignatureParser.parseSimpleClassTypeSignature(SignatureParser.java:262)
        at sun.reflect.generics.parser.SignatureParser.parseClassTypeSignatureSuffix(SignatureParser.java:270)
        at sun.reflect.generics.parser.SignatureParser.parseClassTypeSignature(SignatureParser.java:244)
        at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:228)
        at sun.reflect.generics.parser.SignatureParser.parseTypeSignature(SignatureParser.java:359)
        at sun.reflect.generics.parser.SignatureParser.parseTypeSig(SignatureParser.java:157)
        at sun.reflect.generics.repository.FieldRepository.parse(FieldRepository.java:34)
        at sun.reflect.generics.repository.FieldRepository.parse(FieldRepository.java:24)
        at sun.reflect.generics.repository.AbstractRepository.<init>(AbstractRepository.java:56)
        at sun.reflect.generics.repository.FieldRepository.<init>(FieldRepository.java:30)
        at sun.reflect.generics.repository.FieldRepository.make(FieldRepository.java:48)
        at java.lang.reflect.Field.getGenericInfo(Field.java:84)
        at java.lang.reflect.Field.getGenericType(Field.java:222)
        at Main.main(Main.java:17)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.lang.reflect.*;

class GenericFailure<T>
{
    class Nested
    {
        class Sub {}
    }
    Nested.Sub fails;
}

public class Main {
    public static void main(String[] args) {
        try
        {
            Field f = GenericFailure.class.getDeclaredField("fails");
            Type t = f.getGenericType();
        }
        catch (Exception e)
        {
            System.err.println(e.toString());
        }
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
none, but the following two similar cases are working:

class GenericFailure<T>
{
    class Nested
    {
        class Sub {}
    }
    Nested fails; // fails uses Nested instead Nested.Sub
}

and getType() instead of getGenericType() always yields the right raw type.

Comments
EVALUATION Closing as duplicate of 6476261.
18-06-2011

EVALUATION Will investigate.
14-09-2006