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
27 package sun.misc;
28
29 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
30 @libcore.api.Hide
31 @SuppressWarnings({"unchecked", "deprecation", "all"})
32 public final class Unsafe {
33
Unsafe()34 private Unsafe() { throw new RuntimeException("Stub!"); }
35
36 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
37 @libcore.api.Hide
getUnsafe()38 public static sun.misc.Unsafe getUnsafe() { throw new RuntimeException("Stub!"); }
39
40 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
41 @libcore.api.Hide
objectFieldOffset(java.lang.reflect.Field field)42 public long objectFieldOffset(java.lang.reflect.Field field) { throw new RuntimeException("Stub!"); }
43
44 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
45 @libcore.api.Hide
arrayBaseOffset(java.lang.Class clazz)46 public int arrayBaseOffset(java.lang.Class clazz) { throw new RuntimeException("Stub!"); }
47
48
49 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
50 @libcore.api.Hide
arrayIndexScale(java.lang.Class clazz)51 public int arrayIndexScale(java.lang.Class clazz) { throw new RuntimeException("Stub!"); }
52
53 @libcore.api.Hide
compareAndSwapInt(java.lang.Object obj, long offset, int expectedValue, int newValue)54 public native boolean compareAndSwapInt(java.lang.Object obj, long offset, int expectedValue, int newValue);
55
56 @libcore.api.Hide
compareAndSwapLong(java.lang.Object obj, long offset, long expectedValue, long newValue)57 public native boolean compareAndSwapLong(java.lang.Object obj, long offset, long expectedValue, long newValue);
58
59 @libcore.api.Hide
compareAndSwapObject(java.lang.Object obj, long offset, java.lang.Object expectedValue, java.lang.Object newValue)60 public native boolean compareAndSwapObject(java.lang.Object obj, long offset, java.lang.Object expectedValue, java.lang.Object newValue);
61
62 @libcore.api.Hide
getIntVolatile(java.lang.Object obj, long offset)63 public native int getIntVolatile(java.lang.Object obj, long offset);
64
65 @libcore.api.Hide
putIntVolatile(java.lang.Object obj, long offset, int newValue)66 public native void putIntVolatile(java.lang.Object obj, long offset, int newValue);
67
68 @libcore.api.Hide
getLongVolatile(java.lang.Object obj, long offset)69 public native long getLongVolatile(java.lang.Object obj, long offset);
70
71 @libcore.api.Hide
putLongVolatile(java.lang.Object obj, long offset, long newValue)72 public native void putLongVolatile(java.lang.Object obj, long offset, long newValue);
73
74 @libcore.api.Hide
putObjectVolatile(java.lang.Object obj, long offset, java.lang.Object newValue)75 public native void putObjectVolatile(java.lang.Object obj, long offset, java.lang.Object newValue);
76
77 @libcore.api.Hide
getObjectVolatile(java.lang.Object obj, long offset)78 public native java.lang.Object getObjectVolatile(java.lang.Object obj, long offset);
79
80 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
81 @libcore.api.Hide
getInt(java.lang.Object obj, long offset)82 public native int getInt(java.lang.Object obj, long offset);
83
84 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
85 @libcore.api.Hide
putInt(java.lang.Object obj, long offset, int newValue)86 public native void putInt(java.lang.Object obj, long offset, int newValue);
87
88 @libcore.api.Hide
putOrderedInt(java.lang.Object obj, long offset, int newValue)89 public native void putOrderedInt(java.lang.Object obj, long offset, int newValue);
90
91 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
92 @libcore.api.Hide
getLong(java.lang.Object obj, long offset)93 public native long getLong(java.lang.Object obj, long offset);
94
95 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
96 @libcore.api.Hide
putLong(java.lang.Object obj, long offset, long newValue)97 public native void putLong(java.lang.Object obj, long offset, long newValue);
98
99 @libcore.api.Hide
putOrderedLong(java.lang.Object obj, long offset, long newValue)100 public native void putOrderedLong(java.lang.Object obj, long offset, long newValue);
101
102 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
103 @libcore.api.Hide
getObject(java.lang.Object obj, long offset)104 public native java.lang.Object getObject(java.lang.Object obj, long offset);
105
106 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
107 @libcore.api.Hide
putObject(java.lang.Object obj, long offset, java.lang.Object newValue)108 public native void putObject(java.lang.Object obj, long offset, java.lang.Object newValue);
109
110 @libcore.api.Hide
putOrderedObject(java.lang.Object obj, long offset, java.lang.Object newValue)111 public native void putOrderedObject(java.lang.Object obj, long offset, java.lang.Object newValue);
112
113 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
114 @libcore.api.Hide
getBoolean(java.lang.Object obj, long offset)115 public native boolean getBoolean(java.lang.Object obj, long offset);
116
117 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
118 @libcore.api.Hide
putBoolean(java.lang.Object obj, long offset, boolean newValue)119 public native void putBoolean(java.lang.Object obj, long offset, boolean newValue);
120
121 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
122 @libcore.api.Hide
getByte(java.lang.Object obj, long offset)123 public native byte getByte(java.lang.Object obj, long offset);
124
125 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
126 @libcore.api.Hide
putByte(java.lang.Object obj, long offset, byte newValue)127 public native void putByte(java.lang.Object obj, long offset, byte newValue);
128
129 @libcore.api.Hide
getChar(java.lang.Object obj, long offset)130 public native char getChar(java.lang.Object obj, long offset);
131
132 @libcore.api.Hide
putChar(java.lang.Object obj, long offset, char newValue)133 public native void putChar(java.lang.Object obj, long offset, char newValue);
134
135 @libcore.api.Hide
getShort(java.lang.Object obj, long offset)136 public native short getShort(java.lang.Object obj, long offset);
137
138 @libcore.api.Hide
putShort(java.lang.Object obj, long offset, short newValue)139 public native void putShort(java.lang.Object obj, long offset, short newValue);
140
141 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
142 @libcore.api.Hide
getFloat(java.lang.Object obj, long offset)143 public native float getFloat(java.lang.Object obj, long offset);
144
145 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
146 @libcore.api.Hide
putFloat(java.lang.Object obj, long offset, float newValue)147 public native void putFloat(java.lang.Object obj, long offset, float newValue);
148
149 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
150 @libcore.api.Hide
getDouble(java.lang.Object obj, long offset)151 public native double getDouble(java.lang.Object obj, long offset);
152
153 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
154 @libcore.api.Hide
putDouble(java.lang.Object obj, long offset, double newValue)155 public native void putDouble(java.lang.Object obj, long offset, double newValue);
156
157 @libcore.api.Hide
park(boolean absolute, long time)158 public native void park(boolean absolute, long time);
159
160 @libcore.api.Hide
unpark(java.lang.Object obj)161 public native void unpark(java.lang.Object obj);
162
163 @libcore.api.Hide
allocateInstance(java.lang.Class<?> c)164 public native java.lang.Object allocateInstance(java.lang.Class<?> c);
165
166 @libcore.api.Hide
addressSize()167 public native int addressSize();
168
169 @libcore.api.Hide
pageSize()170 public native int pageSize();
171
172 @libcore.api.Hide
allocateMemory(long bytes)173 public native long allocateMemory(long bytes);
174
175 @libcore.api.Hide
freeMemory(long address)176 public native void freeMemory(long address);
177
178 @libcore.api.Hide
setMemory(long address, long bytes, byte value)179 public native void setMemory(long address, long bytes, byte value);
180
181 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
182 @libcore.api.Hide
getByte(long address)183 public native byte getByte(long address);
184
185 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
186 @libcore.api.Hide
putByte(long address, byte x)187 public native void putByte(long address, byte x);
188
189 @libcore.api.Hide
getShort(long address)190 public native short getShort(long address);
191
192 @libcore.api.Hide
putShort(long address, short x)193 public native void putShort(long address, short x);
194
195 @libcore.api.Hide
getChar(long address)196 public native char getChar(long address);
197
198 @libcore.api.Hide
putChar(long address, char x)199 public native void putChar(long address, char x);
200
201 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
202 @libcore.api.Hide
getInt(long address)203 public native int getInt(long address);
204
205 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
206 @libcore.api.Hide
putInt(long address, int x)207 public native void putInt(long address, int x);
208
209 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
210 @libcore.api.Hide
getLong(long address)211 public native long getLong(long address);
212
213 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
214 @libcore.api.Hide
putLong(long address, long x)215 public native void putLong(long address, long x);
216
217 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
218 @libcore.api.Hide
getFloat(long address)219 public native float getFloat(long address);
220
221 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
222 @libcore.api.Hide
putFloat(long address, float x)223 public native void putFloat(long address, float x);
224
225 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
226 @libcore.api.Hide
getDouble(long address)227 public native double getDouble(long address);
228
229 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
230 @libcore.api.Hide
putDouble(long address, double x)231 public native void putDouble(long address, double x);
232
233 @libcore.api.Hide
copyMemoryToPrimitiveArray(long srcAddr, java.lang.Object dst, long dstOffset, long bytes)234 public native void copyMemoryToPrimitiveArray(long srcAddr, java.lang.Object dst, long dstOffset, long bytes);
235
236 @libcore.api.Hide
copyMemoryFromPrimitiveArray(java.lang.Object src, long srcOffset, long dstAddr, long bytes)237 public native void copyMemoryFromPrimitiveArray(java.lang.Object src, long srcOffset, long dstAddr, long bytes);
238
239 @android.annotation.SystemApi(client = android.annotation.SystemApi.Client.MODULE_LIBRARIES)
240 @libcore.api.Hide
copyMemory(long srcAddr, long dstAddr, long bytes)241 public native void copyMemory(long srcAddr, long dstAddr, long bytes);
242
243 @libcore.api.Hide
getAndAddInt(java.lang.Object o, long offset, int delta)244 public int getAndAddInt(java.lang.Object o, long offset, int delta) { throw new RuntimeException("Stub!"); }
245
246 @libcore.api.Hide
getAndAddLong(java.lang.Object o, long offset, long delta)247 public long getAndAddLong(java.lang.Object o, long offset, long delta) { throw new RuntimeException("Stub!"); }
248
249 @libcore.api.Hide
getAndSetInt(java.lang.Object o, long offset, int newValue)250 public int getAndSetInt(java.lang.Object o, long offset, int newValue) { throw new RuntimeException("Stub!"); }
251
252 @libcore.api.Hide
getAndSetLong(java.lang.Object o, long offset, long newValue)253 public long getAndSetLong(java.lang.Object o, long offset, long newValue) { throw new RuntimeException("Stub!"); }
254
255 @libcore.api.Hide
getAndSetObject(java.lang.Object o, long offset, java.lang.Object newValue)256 public java.lang.Object getAndSetObject(java.lang.Object o, long offset, java.lang.Object newValue) { throw new RuntimeException("Stub!"); }
257
258 @libcore.api.Hide
loadFence()259 public native void loadFence();
260
261 @libcore.api.Hide
storeFence()262 public native void storeFence();
263
264 @libcore.api.Hide
fullFence()265 public native void fullFence();
266
267 @libcore.api.Hide
268 public static final int INVALID_FIELD_OFFSET = -1; // 0xffffffff
269 }
270
271