JDK-5053846 : javac: MethodRef entries are duplicated in the constant pool
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6,7
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_2000
  • CPU: generic,x86
  • Submitted: 2004-05-27
  • Updated: 2024-04-02
  • Resolved: 2013-03-15
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 8
8 b84Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
When compiling the following code, duplicate entries are created in the Constant Pool:

Vector v = new Vector();
Iterator iter = v.iterator();
while (iter.hasNext()) {
   Object o = iter.next();
   Object o2 = o;
}
for (Object o: v) {
   Object o2 = o;
}

From the constant pool (extracted by JRAW):
...
cp4: Method #cp2 #cp29 // java.util.Vector.iterator () -> java.util.Iterator
...
cp7: Method #cp2 #cp29 // java.util.Vector.iterator () -> java.util.Iterator
...

Javac 1.5 beta, build-51
###@###.### 2004-05-27
I just noticed this for a simple program with a try block:

public class TT {
public static void main(java.lang.String[] unused) {
  try {
    System.out.println("try");
  } catch (Exception e) {
    System.out.println("catch");
  }
}
};

    class #25; // #5
    class #25; // #16
    Utf8 "java/lang/Exception"; // #25

While the duplicate constant pool entries might still be valid class file,
this can't be good for download size.

Comments
verified in jdk8 b92
06-06-2013

URL: http://hg.openjdk.java.net/jdk8/jdk8/langtools/rev/fa24eba012bd User: lana Date: 2013-04-02 17:38:19 +0000
02-04-2013

rt.jar is 390 smaller after applying the patch.
15-03-2013

URL: http://hg.openjdk.java.net/jdk8/tl/langtools/rev/fa24eba012bd User: vromero Date: 2013-03-15 09:03:56 +0000
15-03-2013

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
17-07-2004

PUBLIC COMMENTS ...
17-07-2004

EVALUATION While it is not incorrect as it stands, duplicates should be eliminated. ###@###.### 2004-05-27
27-05-2004