PlatformAddresspublic class PlatformAddress extends Object implements Comparable, ICommonDataTypesThe platform address class is an unsafe virtualization of an OS memory block. |
Fields Summary |
---|
static final int | SIZEOFThis final field defines the size of an address on this platform. | public static final PlatformAddress | NULLNULL is the canonical address with address value zero. | public static final IMemorySpy | memorySpy | static final IMemorySystem | osMemory | static final long | UNKNOWN | final int | osaddr | final long | size |
Constructors Summary |
---|
PlatformAddress(int address, long size)
super();
osaddr = address;
this.size = size;
|
Methods Summary |
---|
public final void | autoFree()Sending auto free to an address means that, when this subsystem has
allocated the memory, it will automatically be freed when this object is
collected by the garbage collector if the memory has not already been
freed explicitly.
memorySpy.autoFree(this);
| public final int | compareTo(java.lang.Object other)
if (other == null) {
throw new NullPointerException(); // per spec.
}
if (other instanceof PlatformAddress) {
int otherPA = ((PlatformAddress) other).osaddr;
if (osaddr == otherPA) {
return 0;
}
return osaddr < otherPA ? -1 : 1;
}
throw new ClassCastException(); // per spec.
| public org.apache.harmony.luni.platform.PlatformAddress | duplicate()
return PlatformAddressFactory.on(osaddr, size);
| public final boolean | equals(java.lang.Object other)
return (other instanceof PlatformAddress)
&& (((PlatformAddress) other).osaddr == osaddr);
| public void | free()
// Memory spys can veto the basic free if they determine the memory was
// not allocated.
if (memorySpy.free(this)) {
osMemory.free(osaddr);
}
| public final org.apache.harmony.luni.platform.PlatformAddress | getAddress(int offset)
int addr = getInt(offset);
return PlatformAddressFactory.on(addr);
| public final byte | getByte(int offset)
memorySpy.rangeCheck(this, offset, SIZEOF_JBYTE);
return osMemory.getByte(osaddr + offset);
| public final void | getByteArray(int offset, byte[] bytes, int bytesOffset, int length)
memorySpy.rangeCheck(this, offset, length * SIZEOF_JBYTE);
osMemory.getByteArray(osaddr + offset, bytes, bytesOffset, length);
| public final double | getDouble(int offset, Endianness order)
memorySpy.rangeCheck(this, offset, SIZEOF_JDOUBLE);
return osMemory.getDouble(osaddr + offset, order);
| public final double | getDouble(int offset)
memorySpy.rangeCheck(this, offset, SIZEOF_JDOUBLE);
return osMemory.getDouble(osaddr + offset);
| public final float | getFloat(int offset, Endianness order)
memorySpy.rangeCheck(this, offset, SIZEOF_JFLOAT);
return osMemory.getFloat(osaddr + offset, order);
| public final float | getFloat(int offset)
memorySpy.rangeCheck(this, offset, SIZEOF_JFLOAT);
return osMemory.getFloat(osaddr + offset);
| public final int | getInt(int offset, Endianness order)
memorySpy.rangeCheck(this, offset, SIZEOF_JINT);
return osMemory.getInt(osaddr + offset, order);
| public final int | getInt(int offset)
memorySpy.rangeCheck(this, offset, SIZEOF_JINT);
return osMemory.getInt(osaddr + offset);
| public final long | getLong(int offset, Endianness order)
memorySpy.rangeCheck(this, offset, SIZEOF_JLONG);
return osMemory.getLong(osaddr + offset, order);
| public final long | getLong(int offset)
memorySpy.rangeCheck(this, offset, SIZEOF_JLONG);
return osMemory.getLong(osaddr + offset);
| public final short | getShort(int offset, Endianness order)
memorySpy.rangeCheck(this, offset, SIZEOF_JSHORT);
return osMemory.getShort(osaddr + offset, order);
| public final short | getShort(int offset)
memorySpy.rangeCheck(this, offset, SIZEOF_JSHORT);
return osMemory.getShort(osaddr + offset);
| public final long | getSize()
return size;
| public final int | hashCode()
return (int) osaddr;
| public final boolean | isNULL()
return this == NULL;
| public final void | moveTo(org.apache.harmony.luni.platform.PlatformAddress dest, long numBytes)
osMemory.memmove(dest.osaddr, osaddr, numBytes);
| public org.apache.harmony.luni.platform.PlatformAddress | offsetBytes(int offset)
return PlatformAddressFactory.on(osaddr + offset, size - offset);
| public final void | setAddress(int offset, org.apache.harmony.luni.platform.PlatformAddress address)
osMemory.setAddress(osaddr + offset, address.osaddr);
| public final void | setByte(int offset, byte value)
memorySpy.rangeCheck(this, offset, SIZEOF_JBYTE);
osMemory.setByte(osaddr + offset, value);
| public final void | setByteArray(int offset, byte[] bytes, int bytesOffset, int length)
memorySpy.rangeCheck(this, offset, length * SIZEOF_JBYTE);
osMemory.setByteArray(osaddr + offset, bytes, bytesOffset, length);
| public final void | setDouble(int offset, double value, Endianness order)
memorySpy.rangeCheck(this, offset, SIZEOF_JDOUBLE);
osMemory.setDouble(osaddr + offset, value, order);
| public final void | setDouble(int offset, double value)
memorySpy.rangeCheck(this, offset, SIZEOF_JDOUBLE);
osMemory.setDouble(osaddr + offset, value);
| public final void | setFloat(int offset, float value, Endianness order)
memorySpy.rangeCheck(this, offset, SIZEOF_JFLOAT);
osMemory.setFloat(osaddr + offset, value, order);
| public final void | setFloat(int offset, float value)
memorySpy.rangeCheck(this, offset, SIZEOF_JFLOAT);
osMemory.setFloat(osaddr + offset, value);
| public final void | setInt(int offset, int value, Endianness order)
memorySpy.rangeCheck(this, offset, SIZEOF_JINT);
osMemory.setInt(osaddr + offset, value, order);
| public final void | setInt(int offset, int value)
memorySpy.rangeCheck(this, offset, SIZEOF_JINT);
osMemory.setInt(osaddr + offset, value);
| public final void | setIntArray(int offset, int[] ints, int intsOffset, int length, boolean swap)
memorySpy.rangeCheck(this, offset, length * SIZEOF_JINT);
osMemory.setIntArray(osaddr + offset, ints, intsOffset, length, swap);
| public final void | setLong(int offset, long value, Endianness order)
memorySpy.rangeCheck(this, offset, SIZEOF_JLONG);
osMemory.setLong(osaddr + offset, value, order);
| public final void | setLong(int offset, long value)
memorySpy.rangeCheck(this, offset, SIZEOF_JLONG);
osMemory.setLong(osaddr + offset, value);
| public final void | setShort(int offset, short value, Endianness order)
memorySpy.rangeCheck(this, offset, SIZEOF_JSHORT);
osMemory.setShort(osaddr + offset, value, order);
| public final void | setShort(int offset, short value)
memorySpy.rangeCheck(this, offset, SIZEOF_JSHORT);
osMemory.setShort(osaddr + offset, value);
| public final void | setShortArray(int offset, short[] shorts, int shortsOffset, int length, boolean swap)
memorySpy.rangeCheck(this, offset, length * SIZEOF_JSHORT);
osMemory.setShortArray(osaddr + offset, shorts, shortsOffset, length,
swap);
| public final int | toInt()
return osaddr;
| public final long | toLong()
return osaddr;
| public final java.lang.String | toString()
return "PlatformAddress[" + osaddr + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
|