Note that there are some explanatory texts on larger screens.

plurals
  1. POJava class constant pool duplicates?
    primarykey
    data
    text
    <p>I have decompiled a class with <code>javap</code> and I'm seeing some duplicates in the Constant Pool section, like this:</p> <pre><code> #19 = Class #350 // java/lang/StringBuilder ... Some other class constants here #318 = Class #350 // java/lang/StringBuilder </code></pre> <p>Methodrefs refer to only one of them:</p> <pre><code> #20 = Methodref #19.#351 // java/lang/StringBuilder."&lt;init&gt;":()V #22 = Methodref #19.#353 // java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; #24 = Methodref #19.#355 // java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder; #25 = Methodref #19.#356 // java/lang/StringBuilder.toString:()Ljava/lang/String; #110 = Methodref #19.#445 // java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder; </code></pre> <p>Is this class correct according to <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html" rel="nofollow">The class File Format</a>? I thought that every Class is mentioned just once and referred later by it's index in the bytecode part.</p> <pre><code>$ javac -version javac 1.7.0_15 </code></pre> <p>An other strange thing is in the source of the class representing the Constant Pool in javac <a href="https://github.com/openjdk-mirror/jdk7u-langtools/blob/master/src/share/classes/com/sun/tools/javac/jvm/Pool.java#L98" rel="nofollow">Pool.java</a>. This states that it will not put an object into the the pool if it is already there (with a help of a HashMap). I wonder if the equals()/hashCode() methods of these classes are implmented correctly.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload