< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Symbol.java

Print this page
@  rev 51710 : 8204308: SA: serviceability/sa/TestInstanceKlassSize*.java fails when running in CDS mode
|  Summary: Use longs instead of ints while computing the identity hash of klass symbols
~  Reviewed-by: coleenp, lfoltan
o  rev 50929 : 8205534: Remove SymbolTable dependency from serviceability agent
|  Reviewed-by: gziemski, poonam, jgeorge, hseigel
~

@@ -81,19 +81,20 @@
     return addr.getJByteAt(baseOffset + index);
   }
   // _identity_hash is a short
   private static CIntegerField idHash;
 
-  public int identityHash() {
+  public long identityHash() {
     long addr_value = getAddress().asLongValue();
-    int  addr_bits = (int)(addr_value >> (VM.getVM().getLogMinObjAlignmentInBytes() + 3));
+    long addr_bits =
+      (addr_value >> (VM.getVM().getLogMinObjAlignmentInBytes() + 3)) & 0xffffffffL;
     int  length = (int)getLength();
     int  byte0 = getByteAt(0);
     int  byte1 = getByteAt(1);
-    int  id_hash = (int)(0xffff & idHash.getValue(this.addr));
-    return id_hash |
-           ((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16);
+    long id_hash = 0xffffL & (long)idHash.getValue(this.addr);
+    return (id_hash |
+      ((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16)) & 0xffffffffL;
   }
 
   public boolean equals(byte[] modUTF8Chars) {
     int l = (int) getLength();
     if (l != modUTF8Chars.length) return false;
< prev index next >