1 /* 2 * Copyright (c) 2000, 2013, 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.misc; 27 28 import android.compat.annotation.UnsupportedAppUsage; 29 30 import dalvik.annotation.compat.VersionCodes; 31 32 @SuppressWarnings({"unchecked", "deprecation", "all"}) 33 public final class Unsafe { 34 Unsafe()35 private Unsafe() { 36 throw new RuntimeException("Stub!"); 37 } 38 39 @UnsupportedAppUsage getUnsafe()40 public static sun.misc.Unsafe getUnsafe() { 41 throw new RuntimeException("Stub!"); 42 } 43 44 @UnsupportedAppUsage objectFieldOffset(java.lang.reflect.Field field)45 public long objectFieldOffset(java.lang.reflect.Field field) { 46 throw new RuntimeException("Stub!"); 47 } 48 49 @UnsupportedAppUsage arrayBaseOffset(java.lang.Class clazz)50 public int arrayBaseOffset(java.lang.Class clazz) { 51 throw new RuntimeException("Stub!"); 52 } 53 54 @UnsupportedAppUsage arrayIndexScale(java.lang.Class clazz)55 public int arrayIndexScale(java.lang.Class clazz) { 56 throw new RuntimeException("Stub!"); 57 } 58 59 @UnsupportedAppUsage(maxTargetSdk = VersionCodes.O) getArrayBaseOffsetForComponentType(java.lang.Class component_class)60 private static native int getArrayBaseOffsetForComponentType(java.lang.Class component_class); 61 62 @UnsupportedAppUsage(maxTargetSdk = VersionCodes.O) getArrayIndexScaleForComponentType(java.lang.Class component_class)63 private static native int getArrayIndexScaleForComponentType(java.lang.Class component_class); 64 65 @UnsupportedAppUsage compareAndSwapInt( java.lang.Object obj, long offset, int expectedValue, int newValue)66 public native boolean compareAndSwapInt( 67 java.lang.Object obj, long offset, int expectedValue, int newValue); 68 69 @UnsupportedAppUsage compareAndSwapLong( java.lang.Object obj, long offset, long expectedValue, long newValue)70 public native boolean compareAndSwapLong( 71 java.lang.Object obj, long offset, long expectedValue, long newValue); 72 73 @UnsupportedAppUsage compareAndSwapObject( java.lang.Object obj, long offset, java.lang.Object expectedValue, java.lang.Object newValue)74 public native boolean compareAndSwapObject( 75 java.lang.Object obj, 76 long offset, 77 java.lang.Object expectedValue, 78 java.lang.Object newValue); 79 80 @UnsupportedAppUsage getIntVolatile(java.lang.Object obj, long offset)81 public native int getIntVolatile(java.lang.Object obj, long offset); 82 83 @UnsupportedAppUsage putIntVolatile(java.lang.Object obj, long offset, int newValue)84 public native void putIntVolatile(java.lang.Object obj, long offset, int newValue); 85 86 @UnsupportedAppUsage getLongVolatile(java.lang.Object obj, long offset)87 public native long getLongVolatile(java.lang.Object obj, long offset); 88 89 @UnsupportedAppUsage putLongVolatile(java.lang.Object obj, long offset, long newValue)90 public native void putLongVolatile(java.lang.Object obj, long offset, long newValue); 91 92 @UnsupportedAppUsage getObjectVolatile(java.lang.Object obj, long offset)93 public native java.lang.Object getObjectVolatile(java.lang.Object obj, long offset); 94 95 @UnsupportedAppUsage putObjectVolatile( java.lang.Object obj, long offset, java.lang.Object newValue)96 public native void putObjectVolatile( 97 java.lang.Object obj, long offset, java.lang.Object newValue); 98 99 @UnsupportedAppUsage getInt(java.lang.Object obj, long offset)100 public native int getInt(java.lang.Object obj, long offset); 101 102 @UnsupportedAppUsage putInt(java.lang.Object obj, long offset, int newValue)103 public native void putInt(java.lang.Object obj, long offset, int newValue); 104 105 @UnsupportedAppUsage putOrderedInt(java.lang.Object obj, long offset, int newValue)106 public native void putOrderedInt(java.lang.Object obj, long offset, int newValue); 107 108 @UnsupportedAppUsage getLong(java.lang.Object obj, long offset)109 public native long getLong(java.lang.Object obj, long offset); 110 111 @UnsupportedAppUsage putLong(java.lang.Object obj, long offset, long newValue)112 public native void putLong(java.lang.Object obj, long offset, long newValue); 113 114 @UnsupportedAppUsage putOrderedLong(java.lang.Object obj, long offset, long newValue)115 public native void putOrderedLong(java.lang.Object obj, long offset, long newValue); 116 117 @UnsupportedAppUsage getObject(java.lang.Object obj, long offset)118 public native java.lang.Object getObject(java.lang.Object obj, long offset); 119 120 @UnsupportedAppUsage putObject(java.lang.Object obj, long offset, java.lang.Object newValue)121 public native void putObject(java.lang.Object obj, long offset, java.lang.Object newValue); 122 123 @UnsupportedAppUsage putOrderedObject( java.lang.Object obj, long offset, java.lang.Object newValue)124 public native void putOrderedObject( 125 java.lang.Object obj, long offset, java.lang.Object newValue); 126 127 @UnsupportedAppUsage getBoolean(java.lang.Object obj, long offset)128 public native boolean getBoolean(java.lang.Object obj, long offset); 129 130 @UnsupportedAppUsage putBoolean(java.lang.Object obj, long offset, boolean newValue)131 public native void putBoolean(java.lang.Object obj, long offset, boolean newValue); 132 133 @UnsupportedAppUsage getByte(java.lang.Object obj, long offset)134 public native byte getByte(java.lang.Object obj, long offset); 135 136 @UnsupportedAppUsage putByte(java.lang.Object obj, long offset, byte newValue)137 public native void putByte(java.lang.Object obj, long offset, byte newValue); 138 139 @UnsupportedAppUsage getChar(java.lang.Object obj, long offset)140 public native char getChar(java.lang.Object obj, long offset); 141 142 @UnsupportedAppUsage putChar(java.lang.Object obj, long offset, char newValue)143 public native void putChar(java.lang.Object obj, long offset, char newValue); 144 145 @UnsupportedAppUsage getShort(java.lang.Object obj, long offset)146 public native short getShort(java.lang.Object obj, long offset); 147 148 @UnsupportedAppUsage putShort(java.lang.Object obj, long offset, short newValue)149 public native void putShort(java.lang.Object obj, long offset, short newValue); 150 151 @UnsupportedAppUsage getFloat(java.lang.Object obj, long offset)152 public native float getFloat(java.lang.Object obj, long offset); 153 154 @UnsupportedAppUsage putFloat(java.lang.Object obj, long offset, float newValue)155 public native void putFloat(java.lang.Object obj, long offset, float newValue); 156 157 @UnsupportedAppUsage getDouble(java.lang.Object obj, long offset)158 public native double getDouble(java.lang.Object obj, long offset); 159 160 @UnsupportedAppUsage putDouble(java.lang.Object obj, long offset, double newValue)161 public native void putDouble(java.lang.Object obj, long offset, double newValue); 162 163 @UnsupportedAppUsage park(boolean absolute, long time)164 public void park(boolean absolute, long time) { 165 throw new RuntimeException("Stub!"); 166 } 167 168 @UnsupportedAppUsage unpark(java.lang.Object obj)169 public void unpark(java.lang.Object obj) { 170 throw new RuntimeException("Stub!"); 171 } 172 173 @UnsupportedAppUsage allocateInstance(java.lang.Class<?> c)174 public native java.lang.Object allocateInstance(java.lang.Class<?> c); 175 176 @UnsupportedAppUsage addressSize()177 public native int addressSize(); 178 179 @UnsupportedAppUsage pageSize()180 public native int pageSize(); 181 182 @UnsupportedAppUsage allocateMemory(long bytes)183 public native long allocateMemory(long bytes); 184 185 @UnsupportedAppUsage freeMemory(long address)186 public native void freeMemory(long address); 187 188 @UnsupportedAppUsage setMemory(long address, long bytes, byte value)189 public native void setMemory(long address, long bytes, byte value); 190 191 @UnsupportedAppUsage getByte(long address)192 public native byte getByte(long address); 193 194 @UnsupportedAppUsage putByte(long address, byte x)195 public native void putByte(long address, byte x); 196 197 @UnsupportedAppUsage getShort(long address)198 public native short getShort(long address); 199 200 @UnsupportedAppUsage putShort(long address, short x)201 public native void putShort(long address, short x); 202 203 @UnsupportedAppUsage getChar(long address)204 public native char getChar(long address); 205 206 @UnsupportedAppUsage putChar(long address, char x)207 public native void putChar(long address, char x); 208 209 @UnsupportedAppUsage getInt(long address)210 public native int getInt(long address); 211 212 @UnsupportedAppUsage putInt(long address, int x)213 public native void putInt(long address, int x); 214 215 @UnsupportedAppUsage getLong(long address)216 public native long getLong(long address); 217 218 @UnsupportedAppUsage putLong(long address, long x)219 public native void putLong(long address, long x); 220 221 @UnsupportedAppUsage getFloat(long address)222 public native float getFloat(long address); 223 224 @UnsupportedAppUsage putFloat(long address, float x)225 public native void putFloat(long address, float x); 226 227 @UnsupportedAppUsage getDouble(long address)228 public native double getDouble(long address); 229 230 @UnsupportedAppUsage putDouble(long address, double x)231 public native void putDouble(long address, double x); 232 233 @UnsupportedAppUsage copyMemoryToPrimitiveArray( long srcAddr, java.lang.Object dst, long dstOffset, long bytes)234 public native void copyMemoryToPrimitiveArray( 235 long srcAddr, java.lang.Object dst, long dstOffset, long bytes); 236 237 @UnsupportedAppUsage copyMemoryFromPrimitiveArray( java.lang.Object src, long srcOffset, long dstAddr, long bytes)238 public native void copyMemoryFromPrimitiveArray( 239 java.lang.Object src, long srcOffset, long dstAddr, long bytes); 240 241 @UnsupportedAppUsage copyMemory(long srcAddr, long dstAddr, long bytes)242 public native void copyMemory(long srcAddr, long dstAddr, long bytes); 243 244 @UnsupportedAppUsage getAndAddInt(java.lang.Object o, long offset, int delta)245 public int getAndAddInt(java.lang.Object o, long offset, int delta) { 246 throw new RuntimeException("Stub!"); 247 } 248 249 @UnsupportedAppUsage getAndAddLong(java.lang.Object o, long offset, long delta)250 public long getAndAddLong(java.lang.Object o, long offset, long delta) { 251 throw new RuntimeException("Stub!"); 252 } 253 254 @UnsupportedAppUsage getAndSetInt(java.lang.Object o, long offset, int newValue)255 public int getAndSetInt(java.lang.Object o, long offset, int newValue) { 256 throw new RuntimeException("Stub!"); 257 } 258 259 @UnsupportedAppUsage getAndSetLong(java.lang.Object o, long offset, long newValue)260 public long getAndSetLong(java.lang.Object o, long offset, long newValue) { 261 throw new RuntimeException("Stub!"); 262 } 263 264 @UnsupportedAppUsage getAndSetObject( java.lang.Object o, long offset, java.lang.Object newValue)265 public java.lang.Object getAndSetObject( 266 java.lang.Object o, long offset, java.lang.Object newValue) { 267 throw new RuntimeException("Stub!"); 268 } 269 270 @UnsupportedAppUsage loadFence()271 public native void loadFence(); 272 273 @UnsupportedAppUsage storeFence()274 public native void storeFence(); 275 276 @UnsupportedAppUsage fullFence()277 public native void fullFence(); 278 279 @UnsupportedAppUsage 280 public static final int INVALID_FIELD_OFFSET = -1; // 0xffffffff 281 282 @UnsupportedAppUsage private static final sun.misc.Unsafe THE_ONE; 283 284 static { 285 THE_ONE = null; 286 } 287 288 @UnsupportedAppUsage private static final sun.misc.Unsafe theUnsafe; 289 290 static { 291 theUnsafe = null; 292 } 293 } 294