Use annotated stubs for sun.misc.Unsafe
Bug: 154796679
Test: m stable.art.module.platform.api.stubs.source-update-current-api
Change-Id: Ic72aba4f3abfcdabdbec7b52ece8c0c927aaea71
diff --git a/mmodules/core_platform_api/api/stable_platform/current.txt b/mmodules/core_platform_api/api/stable_platform/current.txt
index fc95587..fe27d68 100644
--- a/mmodules/core_platform_api/api/stable_platform/current.txt
+++ b/mmodules/core_platform_api/api/stable_platform/current.txt
@@ -393,7 +393,9 @@
method public boolean getBoolean(Object, long);
method public byte getByte(Object, long);
method public byte getByte(long);
+ method public double getDouble(Object, long);
method public double getDouble(long);
+ method public float getFloat(Object, long);
method public float getFloat(long);
method public int getInt(Object, long);
method public int getInt(long);
@@ -405,7 +407,9 @@
method public void putBoolean(Object, long, boolean);
method public void putByte(Object, long, byte);
method public void putByte(long, byte);
+ method public void putDouble(Object, long, double);
method public void putDouble(long, double);
+ method public void putFloat(Object, long, float);
method public void putFloat(long, float);
method public void putInt(Object, long, int);
method public void putInt(long, int);
diff --git a/ojluni/annotations/mmodule/sun/misc/Unsafe.annotated.java b/ojluni/annotations/mmodule/sun/misc/Unsafe.annotated.java
index a6711e0..9407d1a 100644
--- a/ojluni/annotations/mmodule/sun/misc/Unsafe.annotated.java
+++ b/ojluni/annotations/mmodule/sun/misc/Unsafe.annotated.java
@@ -27,95 +27,103 @@
// sun.misc.Unsafe is part of the Core Platform API as platform uses protobuf and protobuf uses
// this API for fast structure updates from native code (b/144502743).
-@libcore.api.CorePlatformApi
+@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@libcore.api.Hide
@SuppressWarnings({"unchecked", "deprecation", "all"})
public final class Unsafe {
- private Unsafe() {
- throw new RuntimeException("Stub!");
- }
-
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public static sun.misc.Unsafe getUnsafe() {
throw new RuntimeException("Stub!");
}
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public int arrayBaseOffset(Class clazz) {
throw new RuntimeException("Stub!");
}
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public int arrayIndexScale(Class clazz) {
throw new RuntimeException("Stub!");
}
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void copyMemory(long srcAddr, long destAddr, long bytes);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native boolean getBoolean(Object obj, long offset);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native byte getByte(long address);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native byte getByte(Object obj, long offset);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native double getDouble(Object obj, long offset);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
+ public native double getDouble(long address);
+
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native float getFloat(Object obj, long offset);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
+ public native float getFloat(long address);
+
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native int getInt(long address);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native int getInt(Object obj, long offset);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native long getLong(long address);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native long getLong(Object obj, long offset);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native Object getObject(Object obj, long offset);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public long objectFieldOffset(java.lang.reflect.Field field) {
throw new RuntimeException("Stub!");
}
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void putBoolean(Object obj, long offset, boolean newValue);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void putByte(long address, byte newValue);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void putByte(Object obj, long offset, byte newValue);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void putDouble(Object obj, long offset, double newValue);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
+ public native void putDouble(long address, double newValue);
+
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void putFloat(Object obj, long offset, float newValue);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
+ public native void putFloat(long address, float newValue);
+
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void putInt(long address, int newValue);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void putInt(Object obj, long offset, int newValue);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void putLong(long address, long newValue);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void putLong(Object obj, long offset, long newValue);
- @libcore.api.CorePlatformApi
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public native void putObject(Object obj, long offset, Object newValue);
}
diff --git a/ojluni/src/main/java/sun/misc/Unsafe.java b/ojluni/src/main/java/sun/misc/Unsafe.java
index 5c6a930..e538b73 100644
--- a/ojluni/src/main/java/sun/misc/Unsafe.java
+++ b/ojluni/src/main/java/sun/misc/Unsafe.java
@@ -39,8 +39,6 @@
* @author John R. Rose
* @see #getUnsafe
*/
-// Android-added: stable CorePlatformAPI
-@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public final class Unsafe {
/** Traditional dalvik name. */
private static final Unsafe THE_ONE = new Unsafe();
@@ -57,8 +55,6 @@
* Gets the unique instance of this class. This is only allowed in
* very limited situations.
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public static Unsafe getUnsafe() {
Class<?> caller = Reflection.getCallerClass();
/*
@@ -81,8 +77,6 @@
* instance field
* @return the offset to the field
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public long objectFieldOffset(Field field) {
if (Modifier.isStatic(field.getModifiers())) {
throw new IllegalArgumentException("valid for instance fields only");
@@ -97,8 +91,6 @@
* @param clazz non-{@code null}; class in question; must be an array class
* @return the offset to the initial element
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public int arrayBaseOffset(Class clazz) {
Class<?> component = clazz.getComponentType();
if (component == null) {
@@ -113,8 +105,6 @@
* @param clazz non-{@code null}; class in question; must be an array class
* @return > 0; the size of each element of the array
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public int arrayIndexScale(Class clazz) {
Class<?> component = clazz.getComponentType();
if (component == null) {
@@ -250,8 +240,6 @@
* @param offset offset to the field within {@code obj}
* @return the retrieved value
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native int getInt(Object obj, long offset);
@@ -262,8 +250,6 @@
* @param offset offset to the field within {@code obj}
* @param newValue the value to store
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void putInt(Object obj, long offset, int newValue);
@@ -284,8 +270,6 @@
* @param offset offset to the field within {@code obj}
* @return the retrieved value
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native long getLong(Object obj, long offset);
@@ -296,8 +280,6 @@
* @param offset offset to the field within {@code obj}
* @param newValue the value to store
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void putLong(Object obj, long offset, long newValue);
@@ -318,8 +300,6 @@
* @param offset offset to the field within {@code obj}
* @return the retrieved value
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native Object getObject(Object obj, long offset);
@@ -330,8 +310,6 @@
* @param offset offset to the field within {@code obj}
* @param newValue the value to store
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void putObject(Object obj, long offset, Object newValue);
@@ -353,8 +331,6 @@
* @param offset offset to the field within {@code obj}
* @return the retrieved value
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native boolean getBoolean(Object obj, long offset);
@@ -365,8 +341,6 @@
* @param offset offset to the field within {@code obj}
* @param newValue the value to store
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void putBoolean(Object obj, long offset, boolean newValue);
@@ -377,8 +351,6 @@
* @param offset offset to the field within {@code obj}
* @return the retrieved value
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native byte getByte(Object obj, long offset);
@@ -389,8 +361,6 @@
* @param offset offset to the field within {@code obj}
* @param newValue the value to store
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void putByte(Object obj, long offset, byte newValue);
@@ -557,8 +527,6 @@
* @param address address in memory
* @return {@code byte} value
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native byte getByte(long address);
@@ -568,8 +536,6 @@
* @param address address in memory where to store the value
* @param newValue the value to store
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void putByte(long address, byte x);
@@ -615,8 +581,6 @@
* @param address address in memory
* @return {@code int} value
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native int getInt(long address);
@@ -626,8 +590,6 @@
* @param address address in memory where to store the value
* @param newValue the value to store
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void putInt(long address, int x);
@@ -638,8 +600,6 @@
* @param address address in memory
* @return {@code long} value
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native long getLong(long address);
@@ -649,8 +609,6 @@
* @param address address in memory where to store the value
* @param newValue the value to store
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void putLong(long address, long x);
@@ -660,8 +618,6 @@
* @param address address in memory
* @return {@code long} value
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native float getFloat(long address);
@@ -671,8 +627,6 @@
* @param address address in memory where to store the value
* @param newValue the value to store
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void putFloat(long address, float x);
@@ -682,8 +636,6 @@
* @param address address in memory
* @return {@code double} value
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native double getDouble(long address);
@@ -693,8 +645,6 @@
* @param address address in memory where to store the value
* @param newValue the value to store
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void putDouble(long address, double x);
@@ -730,8 +680,6 @@
* @param dstAddr address of the destination memory to copy to
* @param bytes number of bytes to copy
*/
- // Android-added: stable CorePlatformAPI
- @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
@FastNative
public native void copyMemory(long srcAddr, long dstAddr, long bytes);