JDK-8015927 : Class reference duplicates in constant pool
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7u17
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-05-24
  • Updated: 2014-11-17
  • Resolved: 2014-05-20
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 9
9 b15Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_17 " 
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
generic

A DESCRIPTION OF THE PROBLEM :
After compiling a class with javac and decompiling it with javap I can see duplicates of certain class references in the constant pool section, these classes are always mentioned in method StackMapTables. From the duplicated references always the first one is used only later on in the class. Despite the runtime can work with this but these references are completely unnecessary.

$ javap -v Duplicates.class | grep  " = Class " 
    #2 = Class              #22            //  java/lang/StringBuilder
    #7 = Class              #26            //  Duplicates
    #8 = Class              #27            //  java/lang/Object
  #16 = Class              #22            //  java/lang/StringBuilder    <- never used
  #17 = Class              #26            //  Duplicates    <- never used
  #18 = Class              #28            //  java/lang/String

REGRESSION.  Last worked in version 5.0

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the given example source with javac and decompile it the code with javap -v FILE | grep  " = Class " . Check if you can find any duplicates.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
You will see that StringBuilder and Duplicates classes are mentioned twice.
ACTUAL -
    #2 = Class              #22            //  java/lang/StringBuilder
    #7 = Class              #26            //  Duplicates
    #8 = Class              #27            //  java/lang/Object
  #16 = Class              #22            //  java/lang/StringBuilder
  #17 = Class              #26            //  Duplicates
  #18 = Class              #28            //  java/lang/String

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
class Duplicates {
    String concat(String s1, String s2) {
      return s1 + (s2 == s1 ?  "  "  : s2);
    }
}
---------- END SOURCE ----------
Comments
AutoVerify: Tests ran fine for JDK9-b15
30-06-2014

This is a minor issue to be fixed in a later release.
20-06-2013

Inelegant but not a P3 bug
04-06-2013