JDK-8020194 : Class.getGenericInterfaces()[index].toString() duplicates outer class name
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2013-07-05
  • Updated: 2016-10-20
  • Resolved: 2016-10-20
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_25 " 
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux  3.2.0-48-generic #74-Ubuntu SMP Thu Jun 6 19:43:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
Code like  " MyClass.class.getGenericInterfaces()[0].toString() "  returnes string contains outer class name repeated twice if MyClass is an inner class. Bug appears in 7u25, 6u37 and OpenJDK 6.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the code below.
You will see returned (errorneous) and expected values.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
testcase.TestCase$BaseInterface<java.lang.String>
ACTUAL -
testcase.TestCase.testcase.TestCase$BaseInterface<java.lang.String>

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package testcase;

public class TestCase {
    public interface BaseInterface<T> { }
    public class MyClass implements BaseInterface<String> { }

    public static void main(String[] args) {
        String genericInterface = MyClass.class.getGenericInterfaces()[0].toString();
        System.out.println(genericInterface);
        System.out.println( " Expected:  "  + BaseInterface.class.getName() +
             " <java.lang.String> " );
    }
}
---------- END SOURCE ----------
Comments
I found out that this issue is solved in JDK 9 b129. After analysis and simple debugging I see that this is the same issue with JDK-8054213 Therefore, I close this as duplicate of that one.
20-10-2016

May be related to JDK-6376382.
12-07-2013