Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are right. <code>Constant pool</code> doesn't require <em>duplicate entries</em>. One class should only have 1 entry in the constant pool.</p> <p>This definitely seems to be a bug. Check this out. Someone has logged this as bug and it has been acknowledged >> <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6746955" rel="nofollow">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6746955</a></p> <p><strong>Answer Updated:</strong></p> <p>One more thing I want to point out here is that adding duplicate entries does not make any sense because it increases the byte size of the class file and that destroys the main purpose of java class file's compactness, portability and faster network mobility. The class file should be as much compact as possible.</p> <p><strong>By the way</strong>, class file is valid because it adheres to class file format defined. But its not an ideal one.</p> <p>As I forgot to, <strong>answer your second Question:</strong></p> <p>JVM assigns <em>similar looking</em> objects the same hashcode but still they will be distinct. JVM will never create 2 objects identical unless both are referring to same object. Hashcode is nothing but a partition system. Similar looking objects are placed into same partition so that the traversing time becomes less while searching for a particular object. Hashcode is nothing but a pointer to that small partition. </p> <p>Only because it is not possible to assign distinct hashcode to each new object(because number of objects can outnumber possible number of unique hashcode creation. Please refer to possible collision in hash algorithm), you may find distinct objects having same hashcode. But here is the thing, 2 objects pointing to same reference in the memory must have the same hashcode.</p> <p><strong>So</strong>, moral of the story, JVM makes sure that two distinct objects can never be identical even if their hashcodes are.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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