< prev index next >

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

Print this page




  89     int  length = (int)getLength();
  90     int  byte0 = getByteAt(0);
  91     int  byte1 = getByteAt(1);
  92     int  id_hash = (int)(0xffff & idHash.getValue(this.addr));
  93     return id_hash |
  94            ((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16);
  95   }
  96 
  97   public boolean equals(byte[] modUTF8Chars) {
  98     int l = (int) getLength();
  99     if (l != modUTF8Chars.length) return false;
 100     while (l-- > 0) {
 101       if (modUTF8Chars[l] != getByteAt(l)) return false;
 102     }
 103     if (Assert.ASSERTS_ENABLED) {
 104       Assert.that(l == -1, "we should be at the beginning");
 105     }
 106     return true;
 107   }
 108 




 109   public byte[] asByteArray() {
 110     int length = (int) getLength();
 111     byte [] result = new byte [length];
 112     for (int index = 0; index < length; index++) {
 113       result[index] = getByteAt(index);
 114     }
 115     return result;
 116   }
 117 
 118   public String asString() {
 119     // Decode the byte array and return the string.
 120     try {
 121       return readModifiedUTF8(asByteArray());
 122     } catch(Exception e) {
 123       System.err.println(addr);
 124       e.printStackTrace();
 125       return null;
 126     }
 127   }
 128 




  89     int  length = (int)getLength();
  90     int  byte0 = getByteAt(0);
  91     int  byte1 = getByteAt(1);
  92     int  id_hash = (int)(0xffff & idHash.getValue(this.addr));
  93     return id_hash |
  94            ((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16);
  95   }
  96 
  97   public boolean equals(byte[] modUTF8Chars) {
  98     int l = (int) getLength();
  99     if (l != modUTF8Chars.length) return false;
 100     while (l-- > 0) {
 101       if (modUTF8Chars[l] != getByteAt(l)) return false;
 102     }
 103     if (Assert.ASSERTS_ENABLED) {
 104       Assert.that(l == -1, "we should be at the beginning");
 105     }
 106     return true;
 107   }
 108 
 109   public boolean equals(String string) {
 110     return asString().equals(string);
 111   }
 112 
 113   public byte[] asByteArray() {
 114     int length = (int) getLength();
 115     byte [] result = new byte [length];
 116     for (int index = 0; index < length; index++) {
 117       result[index] = getByteAt(index);
 118     }
 119     return result;
 120   }
 121 
 122   public String asString() {
 123     // Decode the byte array and return the string.
 124     try {
 125       return readModifiedUTF8(asByteArray());
 126     } catch(Exception e) {
 127       System.err.println(addr);
 128       e.printStackTrace();
 129       return null;
 130     }
 131   }
 132 


< prev index next >