JDK-4979440 : (reflect) Method.getGenericReturnType() fails on jdk class
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2004-01-16
  • Updated: 2012-09-28
  • Resolved: 2004-02-06
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.
Other
5.0 b38Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description

Name: siR10004			Date: 01/16/2004



Generic signature parser fails to parse return type of 
the method 'getAnnotation ' from 
the class 'java.lang.reflect.AccessibleObject'.

To reproduce, run the following simple script:
-----------------------------------------------------------
#!/bin/sh
set -x

JH=/home/isl/space/Refs/jdks/jdk1.5.0-b33/solaris-sparc

cat > Test.java << EOF
import java.lang.reflect.*;
public class Test {
    public static void main (String[] args) throws Throwable {
        Class c = Class.forName("java.lang.reflect.AccessibleObject");
        Method[] ms = c.getDeclaredMethods();
        for (int i = 0; i < ms.length; i++) {
            System.out.println("method " + ms[i].getName());
            ms[i].getGenericReturnType();
        }
    }
}
EOF

$JH/bin/javac -source 1.5 -target 1.5 Test.java
$JH/bin/java -cp . Test
-----------------------------------------------------------

Method.getGenericReturnType() fails with stack dump

method getAnnotation
Exception in thread "main" java.lang.reflect.GenericSignatureFormatError
        at sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:103)
        at 
sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:233)
        at 
sun.reflect.generics.parser.SignatureParser.parseZeroOrMoreBounds(SignatureParser.java:399)
        at 
sun.reflect.generics.parser.SignatureParser.parseFormalTypeParameter(SignatureParser.java:199)
        at 
sun.reflect.generics.parser.SignatureParser.parseFormalTypeParameters(SignatureParser.java:188)
        at 
sun.reflect.generics.parser.SignatureParser.parseZeroOrMoreFormalTypeParameters(SignatureParser.ja
va:177)
        at 
sun.reflect.generics.parser.SignatureParser.parseMethodTypeSignature(SignatureParser.java:420)
        at sun.reflect.generics.parser.SignatureParser.parseMethodSig(SignatureParser.java:141)
        at 
sun.reflect.generics.repository.ConstructorRepository.parse(ConstructorRepository.java:37)
        at 
sun.reflect.generics.repository.ConstructorRepository.parse(ConstructorRepository.java:25)
        at sun.reflect.generics.repository.AbstractRepository.<init>(AbstractRepository.java:56)
        at 
sun.reflect.generics.repository.GenericDeclRepository.<init>(GenericDeclRepository.java:30)
        at 
sun.reflect.generics.repository.ConstructorRepository.<init>(ConstructorRepository.java:33)
        at sun.reflect.generics.repository.MethodRepository.<init>(MethodRepository.java:28)
        at sun.reflect.generics.repository.MethodRepository.make(MethodRepository.java:41)
        at java.lang.reflect.Method.getGenericInfo(Method.java:88)
        at java.lang.reflect.Method.getGenericReturnType(Method.java:230)
        at Test.main(Test.java:8)
        
This bug is reproduced on b33.        

This bug cases failure of jck SignatureTest.

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

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b38 tiger-beta2 VERIFIED IN: tiger-beta2
14-06-2004

SUGGESTED FIX src/share/classes/sun/reflect/generics/parser> SignatureParser.java < ------- SignatureParser.java ------- 397c397,398 < while (current() == ':') { --- > > if (current() == ':') { 399c400,412 < fts.add(parseFieldTypeSignature()); --- > switch(current()) { > case ':': // empty class bound > break; > > default: // parse class bound > fts.add(parseFieldTypeSignature()); > } > > // zero or more interface bounds > while (current() == ':') { > advance(); > fts.add(parseFieldTypeSignature()); > } 400a414 > ###@###.### 2004-01-22
22-01-2004

EVALUATION The given program does work with builds 30 and 31 (this functionality was added in build 30). Suspect regression caused directly or indirectly by class file format changes; investigating. ###@###.### 2004-01-20 Minor bug in signature parser. ###@###.### 2004-01-22
20-01-2004