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 ----------