< prev index next >

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

Print this page

  1 /*
  2  * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

 92     }
 93   }
 94 
 95   public boolean isA(Klass k) {
 96     return getKlass().isSubtypeOf(k);
 97   }
 98 
 99   // Returns the byte size of this object
100   public long getObjectSize() {
101     Klass k = getKlass();
102     // All other types should be overriding getObjectSize directly
103     return ((InstanceKlass)k).getObjectSize(this);
104   }
105 
106   // Type test operations
107   public boolean isInstance()          { return false; }
108   public boolean isInstanceRef()       { return false; }
109   public boolean isArray()             { return false; }
110   public boolean isObjArray()          { return false; }
111   public boolean isTypeArray()         { return false; }

112   public boolean isThread()            { return false; }
113 
114   // Align the object size.
115   public static long alignObjectSize(long size) {
116     return VM.getVM().alignUp(size, VM.getVM().getMinObjAlignmentInBytes());
117   }
118 
119   // All vm's align longs, so pad out certain offsets.
120   public static long alignObjectOffset(long offset) {
121     return VM.getVM().alignUp(offset, VM.getVM().getBytesPerLong());
122   }
123 
124   public boolean equals(Object obj) {
125     if (obj instanceof Oop other) {
126       return getHandle().equals(other.getHandle());
127     }
128     return false;
129  }
130 
131   public int hashCode() { return getHandle().hashCode(); }

  1 /*
  2  * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

 92     }
 93   }
 94 
 95   public boolean isA(Klass k) {
 96     return getKlass().isSubtypeOf(k);
 97   }
 98 
 99   // Returns the byte size of this object
100   public long getObjectSize() {
101     Klass k = getKlass();
102     // All other types should be overriding getObjectSize directly
103     return ((InstanceKlass)k).getObjectSize(this);
104   }
105 
106   // Type test operations
107   public boolean isInstance()          { return false; }
108   public boolean isInstanceRef()       { return false; }
109   public boolean isArray()             { return false; }
110   public boolean isObjArray()          { return false; }
111   public boolean isTypeArray()         { return false; }
112   public boolean isFlatArray()         { return false; }
113   public boolean isThread()            { return false; }
114 
115   // Align the object size.
116   public static long alignObjectSize(long size) {
117     return VM.getVM().alignUp(size, VM.getVM().getMinObjAlignmentInBytes());
118   }
119 
120   // All vm's align longs, so pad out certain offsets.
121   public static long alignObjectOffset(long offset) {
122     return VM.getVM().alignUp(offset, VM.getVM().getBytesPerLong());
123   }
124 
125   public boolean equals(Object obj) {
126     if (obj instanceof Oop other) {
127       return getHandle().equals(other.getHandle());
128     }
129     return false;
130  }
131 
132   public int hashCode() { return getHandle().hashCode(); }
< prev index next >