Details
-
Enhancement
-
Resolution: Fixed
-
P5
-
6, 7
-
b84
-
generic, x86
-
generic, windows_2000
-
Verified
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.
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.
Attachments
Issue Links
- duplicates
-
JDK-6746955 unused duplicate entries in constant pool
- Closed
- relates to
-
JDK-8042343 UniqueType cannot be safely used with HashMaps
- Resolved
-
JDK-8011432 javac, compiler regression iterable + captured type
- Closed
-
JDK-8038975 Access control in enhanced for
- Resolved
-
JDK-8309751 Duplicate constant pool entries added during default method processing
- Resolved
-
JDK-8015927 Class reference duplicates in constant pool
- Closed
(1 relates to)