--- old/src/share/classes/sun/misc/Unsafe.java 2013-08-19 14:02:51.000000000 -0700 +++ new/src/share/classes/sun/misc/Unsafe.java 2013-08-19 14:02:51.000000000 -0700 @@ -186,7 +186,7 @@ *

* Unless the reference x being stored is either null * or matches the field type, the results are undefined. - * If the reference o is non-null, car marks or + * If the reference o is non-null, card marks or * other store barriers for that object (if the VM requires them) * are updated. * @see #putInt(Object, int, int) @@ -434,6 +434,68 @@ public native void putDouble(long address, double x); /** + * Possible storage modes for references. + * + * The {@link StorageMode#DEFAULT} storage mode uses the JVM's setting for the respective + * storage class. + */ + public enum StorageMode { + DEFAULT, + UNCOMPRESSED_OOP, + COMPRESSED_OOP, + UNCOMPRESSED_KLASS, + COMPRESSED_KLASS; + + static { + for (StorageMode mode : StorageMode.values()) { + setStorageModeConstant(mode.name(), mode.ordinal()); + } + }; + } + + /** + * Tell the JVM about the storage mode values. + */ + private static native void setStorageModeConstant(String name, int ordinal); + + /** + * Fetches a reference value from a given Java variable using the given storage mode. + * @see #getInt(Object, long) + * @since 1.8 + */ + public native Object getObject(Object o, long offset, StorageMode mode); + + /** + * Stores a reference value into a given Java variable using the given storage mode. + *

+ * Unless the reference x being stored is either null + * or matches the field type, the results are undefined. + * If the reference o is non-null, card marks or + * other store barriers for that object (if the VM requires them) + * are updated. + * @see #putInt(Object, int, int) + * @since 1.8 + */ + public native void putObject(Object o, long offset, Object x, StorageMode mode); + + /** + * Fetches a meta data reference value from a given Java variable using the given storage mode. + * @see #getInt(Object, long) + * @since 1.8 + */ + public native long getMetadata(Object o, long offset, StorageMode mode); + + /** + * Stores a meta data reference value into a given Java variable using the given storage mode. + *

+ * Unless the reference x being stored is either null + * or matches the field type, the results are undefined. + * @see #putInt(Object, int, int) + * @since 1.8 + */ + public native void putMetadata(Object o, long offset, long x, StorageMode mode); + + /** * Fetches a native pointer from a given memory address. If the address is * zero, or does not point into a block obtained from {@link * #allocateMemory}, the results are undefined.