public interface Address
This is the bottom-most interface which abstracts address access for both debugging and introspection. In the situation of debugging a target VM, these routines can throw the specified RuntimeExceptions to indicate failure and allow recovery of the debugging system. If these are used for introspecting the current VM and implementing functionality in it, however, it is expected that these kinds of failures will not occur and, in fact, a crash will occur if the situation arises where they would have been thrown.
Addresses are immutable. Further, it was decided not to expose the representation of the Address (and provide a corresponding factory method from, for example, long to Address). Unfortunately, because of the existence of C and "reuse" of low bits of pointers, it is occasionally necessary to perform logical operations like masking off the low bits of an "address". While these operations could be used to generate arbitrary Address objects, allowing this is not the intent of providing these operations.
This interface is able to fetch all Java primitive types, addresses, oops, and C integers of arbitrary size (see @see sun.jvm.hotspot.types.CIntegerType for further discussion). Note that the result of the latter is restricted to fitting into a 64-bit value and the high-order bytes will be silently discarded if too many bytes are requested.
Implementations may have restrictions, for example that the Java-related routines may not be called until a certain point in the bootstrapping process once the sizes of the Java primitive types are known. (The current implementation has that property.)
A note of warning: in C addresses, when represented as integers, are usually represented with unsigned types. Unfortunately, there are no unsigned primitive types in Java, so care will have to be taken in the implementation of this interface if using longs as the representation for 64-bit correctness. This is not so simple for the comparison operators.
Modifier and Type | Method and Description |
---|---|
Address |
addOffsetTo(long offset)
This throws an UnsupportedOperationException if this address happens
to actually be an OopHandle, because interior object pointers
are not allowed.
|
OopHandle |
addOffsetToAsOopHandle(long offset)
This method had to be added in order to support heap iteration
in the debugging system, and is effectively the dangerous
operation of allowing interior object pointers.
|
Address |
andWithMask(long mask)
This throws an UnsupportedOperationException if this address happens
to actually be an OopHandle.
|
boolean |
equals(java.lang.Object arg)
This is stated explicitly here because it is important for
implementations to understand that equals() and hashCode() must
absolutely, positively work properly -- i.e., two Address
objects representing the same address are both equal (via
equals()) and have the same hash code.
|
Address |
getAddressAt(long offset)
This returns null if the address at the given offset is NULL.
|
long |
getCIntegerAt(long offset,
long numBytes,
boolean isUnsigned) |
Address |
getCompKlassAddressAt(long offset) |
Address |
getCompOopAddressAt(long offset)
Returns the decoded address at the given offset
|
OopHandle |
getCompOopHandleAt(long offset) |
boolean |
getJBooleanAt(long offset) |
byte |
getJByteAt(long offset) |
char |
getJCharAt(long offset) |
double |
getJDoubleAt(long offset) |
float |
getJFloatAt(long offset) |
int |
getJIntAt(long offset) |
long |
getJLongAt(long offset) |
short |
getJShortAt(long offset) |
OopHandle |
getOopHandleAt(long offset)
This returns null if the address at the given offset is NULL.
|
boolean |
greaterThan(Address arg)
Performs unsigned comparison "this > arg".
|
boolean |
greaterThanOrEqual(Address arg)
Performs unsigned comparison "this >= arg".
|
int |
hashCode()
This is stated explicitly here because it is important for
implementations to understand that equals() and hashCode() must
absolutely, positively work properly -- i.e., two Address
objects representing the same address are both equal (via
equals()) and have the same hash code.
|
boolean |
lessThan(Address arg)
Performs unsigned comparison "this < arg".
|
boolean |
lessThanOrEqual(Address arg)
Performs unsigned comparison "this <= arg".
|
long |
minus(Address arg)
Performs the subtraction "this - arg", returning the resulting
offset in bytes.
|
Address |
orWithMask(long mask)
This throws an UnsupportedOperationException if this address happens
to actually be an OopHandle.
|
void |
setAddressAt(long offset,
Address value)
Sets an Address at the specified location.
|
void |
setCIntegerAt(long offset,
long numBytes,
long value)
Sets a C integer numBytes in size at the specified offset.
|
void |
setJBooleanAt(long offset,
boolean value) |
void |
setJByteAt(long offset,
byte value) |
void |
setJCharAt(long offset,
char value) |
void |
setJDoubleAt(long offset,
double value) |
void |
setJFloatAt(long offset,
float value) |
void |
setJIntAt(long offset,
int value) |
void |
setJLongAt(long offset,
long value) |
void |
setJShortAt(long offset,
short value) |
void |
setOopHandleAt(long offset,
OopHandle value) |
Address |
xorWithMask(long mask)
This throws an UnsupportedOperationException if this address happens
to actually be an OopHandle.
|
boolean equals(java.lang.Object arg)
equals
in class java.lang.Object
int hashCode()
hashCode
in class java.lang.Object
long getCIntegerAt(long offset, long numBytes, boolean isUnsigned) throws UnmappedAddressException, UnalignedAddressException
Address getAddressAt(long offset) throws UnmappedAddressException, UnalignedAddressException
Address getCompOopAddressAt(long offset) throws UnmappedAddressException, UnalignedAddressException
Address getCompKlassAddressAt(long offset) throws UnmappedAddressException, UnalignedAddressException
boolean getJBooleanAt(long offset) throws UnmappedAddressException, UnalignedAddressException
byte getJByteAt(long offset) throws UnmappedAddressException, UnalignedAddressException
char getJCharAt(long offset) throws UnmappedAddressException, UnalignedAddressException
double getJDoubleAt(long offset) throws UnmappedAddressException, UnalignedAddressException
float getJFloatAt(long offset) throws UnmappedAddressException, UnalignedAddressException
int getJIntAt(long offset) throws UnmappedAddressException, UnalignedAddressException
long getJLongAt(long offset) throws UnmappedAddressException, UnalignedAddressException
short getJShortAt(long offset) throws UnmappedAddressException, UnalignedAddressException
OopHandle getOopHandleAt(long offset) throws UnmappedAddressException, UnalignedAddressException, NotInHeapException
OopHandle getCompOopHandleAt(long offset) throws UnmappedAddressException, UnalignedAddressException, NotInHeapException
void setCIntegerAt(long offset, long numBytes, long value)
void setAddressAt(long offset, Address value)
void setJBooleanAt(long offset, boolean value) throws UnmappedAddressException, UnalignedAddressException
void setJByteAt(long offset, byte value) throws UnmappedAddressException, UnalignedAddressException
void setJCharAt(long offset, char value) throws UnmappedAddressException, UnalignedAddressException
void setJDoubleAt(long offset, double value) throws UnmappedAddressException, UnalignedAddressException
void setJFloatAt(long offset, float value) throws UnmappedAddressException, UnalignedAddressException
void setJIntAt(long offset, int value) throws UnmappedAddressException, UnalignedAddressException
void setJLongAt(long offset, long value) throws UnmappedAddressException, UnalignedAddressException
void setJShortAt(long offset, short value) throws UnmappedAddressException, UnalignedAddressException
void setOopHandleAt(long offset, OopHandle value) throws UnmappedAddressException, UnalignedAddressException
Address addOffsetTo(long offset) throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
OopHandle addOffsetToAsOopHandle(long offset) throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
long minus(Address arg)
boolean lessThan(Address arg)
boolean lessThanOrEqual(Address arg)
boolean greaterThan(Address arg)
boolean greaterThanOrEqual(Address arg)
Address andWithMask(long mask) throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
Address orWithMask(long mask) throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
Address xorWithMask(long mask) throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.