--- jsr166/src/jsr166e/extra/AtomicDouble.java 2011/10/25 19:21:27 1.11
+++ jsr166/src/jsr166e/extra/AtomicDouble.java 2013/03/04 16:12:26 1.18
@@ -19,7 +19,7 @@ import static java.lang.Double.longBitsT
* this class does extend {@code Number} to allow uniform access by
* tools and utilities that deal with numerically-based classes.
*
- *
This class compares primitive {@code double}
+ * This class compares primitive {@code double}
* values in methods such as {@link #compareAndSet} by comparing their
* bitwise representation using {@link Double#doubleToRawLongBits},
* which differs from both the primitive double {@code ==} operator
@@ -40,7 +40,7 @@ import static java.lang.Double.longBitsT
public class AtomicDouble extends Number implements java.io.Serializable {
private static final long serialVersionUID = -8405198993435143622L;
- private volatile transient long value;
+ private transient volatile long value;
/**
* Creates a new {@code AtomicDouble} with the given initial value.
@@ -123,11 +123,10 @@ public class AtomicDouble extends Number
* if the current value is bitwise equal
* to the expected value.
*
- *
May
- * fail spuriously
- * and does not provide ordering guarantees, so is only rarely an
- * appropriate alternative to {@code compareAndSet}.
+ * May fail spuriously and does not provide ordering guarantees
,
+ * so is only rarely an appropriate alternative to {@code compareAndSet}.
*
* @param expect the expected value
* @param update the new value
@@ -216,7 +215,7 @@ public class AtomicDouble extends Number
* @serialData The current value is emitted (a {@code double}).
*/
private void writeObject(java.io.ObjectOutputStream s)
- throws java.io.IOException{
+ throws java.io.IOException {
s.defaultWriteObject();
s.writeDouble(get());
@@ -253,21 +252,23 @@ public class AtomicDouble extends Number
private static sun.misc.Unsafe getUnsafe() {
try {
return sun.misc.Unsafe.getUnsafe();
- } catch (SecurityException se) {
- try {
- return java.security.AccessController.doPrivileged
- (new java.security
- .PrivilegedExceptionAction() {
- public sun.misc.Unsafe run() throws Exception {
- java.lang.reflect.Field f = sun.misc
- .Unsafe.class.getDeclaredField("theUnsafe");
- f.setAccessible(true);
- return (sun.misc.Unsafe) f.get(null);
- }});
- } catch (java.security.PrivilegedActionException e) {
- throw new RuntimeException("Could not initialize intrinsics",
- e.getCause());
- }
+ } catch (SecurityException tryReflectionInstead) {}
+ try {
+ return java.security.AccessController.doPrivileged
+ (new java.security.PrivilegedExceptionAction() {
+ public sun.misc.Unsafe run() throws Exception {
+ Class k = sun.misc.Unsafe.class;
+ for (java.lang.reflect.Field f : k.getDeclaredFields()) {
+ f.setAccessible(true);
+ Object x = f.get(null);
+ if (k.isInstance(x))
+ return k.cast(x);
+ }
+ throw new NoSuchFieldError("the Unsafe");
+ }});
+ } catch (java.security.PrivilegedActionException e) {
+ throw new RuntimeException("Could not initialize intrinsics",
+ e.getCause());
}
}
}