262 /**
263 * Standard hotspot implementation using intrinsics
264 */
265 private static class AtomicIntegerFieldUpdaterImpl<T> extends AtomicIntegerFieldUpdater<T> {
266 private static final Unsafe unsafe = Unsafe.getUnsafe();
267 private final long offset;
268 private final Class<T> tclass;
269 private final Class cclass;
270
271 AtomicIntegerFieldUpdaterImpl(Class<T> tclass, String fieldName) {
272 Field field = null;
273 Class caller = null;
274 int modifiers = 0;
275 try {
276 field = tclass.getDeclaredField(fieldName);
277 caller = sun.reflect.Reflection.getCallerClass(3);
278 modifiers = field.getModifiers();
279 sun.reflect.misc.ReflectUtil.ensureMemberAccess(
280 caller, tclass, null, modifiers);
281 sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
282 } catch(Exception ex) {
283 throw new RuntimeException(ex);
284 }
285
286 Class fieldt = field.getType();
287 if (fieldt != int.class)
288 throw new IllegalArgumentException("Must be integer type");
289
290 if (!Modifier.isVolatile(modifiers))
291 throw new IllegalArgumentException("Must be volatile type");
292
293 this.cclass = (Modifier.isProtected(modifiers) &&
294 caller != tclass) ? caller : null;
295 this.tclass = tclass;
296 offset = unsafe.objectFieldOffset(field);
297 }
298
299 private void fullCheck(T obj) {
300 if (!tclass.isInstance(obj))
301 throw new ClassCastException();
302 if (cclass != null)
|
262 /**
263 * Standard hotspot implementation using intrinsics
264 */
265 private static class AtomicIntegerFieldUpdaterImpl<T> extends AtomicIntegerFieldUpdater<T> {
266 private static final Unsafe unsafe = Unsafe.getUnsafe();
267 private final long offset;
268 private final Class<T> tclass;
269 private final Class cclass;
270
271 AtomicIntegerFieldUpdaterImpl(Class<T> tclass, String fieldName) {
272 Field field = null;
273 Class caller = null;
274 int modifiers = 0;
275 try {
276 field = tclass.getDeclaredField(fieldName);
277 caller = sun.reflect.Reflection.getCallerClass(3);
278 modifiers = field.getModifiers();
279 sun.reflect.misc.ReflectUtil.ensureMemberAccess(
280 caller, tclass, null, modifiers);
281 sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
282 } catch (Exception ex) {
283 throw new RuntimeException(ex);
284 }
285
286 Class fieldt = field.getType();
287 if (fieldt != int.class)
288 throw new IllegalArgumentException("Must be integer type");
289
290 if (!Modifier.isVolatile(modifiers))
291 throw new IllegalArgumentException("Must be volatile type");
292
293 this.cclass = (Modifier.isProtected(modifiers) &&
294 caller != tclass) ? caller : null;
295 this.tclass = tclass;
296 offset = unsafe.objectFieldOffset(field);
297 }
298
299 private void fullCheck(T obj) {
300 if (!tclass.isInstance(obj))
301 throw new ClassCastException();
302 if (cclass != null)
|