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

javac: MethodRef entries are duplicated in the constant pool

XMLWordPrintable

    • b84
    • generic, x86
    • generic, windows_2000
    • Verified

      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.

            vromero Vicente Arturo Romero Zaldivar
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: