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

Class.getGenericInterfaces()[index].toString() duplicates outer class name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 7
    • core-libs

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

      Attachments

        Issue Links

          Activity

            People

              akosarev Artem Kosarev (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: