ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166e/extra/AtomicDouble.java
(Generate patch)

Comparing jsr166/src/jsr166e/extra/AtomicDouble.java (file contents):
Revision 1.12 by jsr166, Tue Oct 25 20:21:25 2011 UTC vs.
Revision 1.17 by jsr166, Mon Mar 4 16:09:25 2013 UTC

# Line 19 | Line 19 | import static java.lang.Double.longBitsT
19   * this class does extend {@code Number} to allow uniform access by
20   * tools and utilities that deal with numerically-based classes.
21   *
22 < * <p><a name="bitEquals">This class compares primitive {@code double}
22 > * <p id="bitEquals">This class compares primitive {@code double}
23   * values in methods such as {@link #compareAndSet} by comparing their
24   * bitwise representation using {@link Double#doubleToRawLongBits},
25   * which differs from both the primitive double {@code ==} operator
# Line 123 | Line 123 | public class AtomicDouble extends Number
123       * if the current value is <a href="#bitEquals">bitwise equal</a>
124       * to the expected value.
125       *
126 <     * <p>May <a
126 >     * <p><a
127       * href="http://download.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/package-summary.html#Spurious">
128 <     * fail spuriously</a>
129 <     * and does not provide ordering guarantees, so is only rarely an
130 <     * appropriate alternative to {@code compareAndSet}.
128 >
129 >     * May fail spuriously and does not provide ordering guarantees</a>,
130 >     * so is only rarely an appropriate alternative to {@code compareAndSet}.
131       *
132       * @param expect the expected value
133       * @param update the new value
# Line 216 | Line 216 | public class AtomicDouble extends Number
216       * @serialData The current value is emitted (a {@code double}).
217       */
218      private void writeObject(java.io.ObjectOutputStream s)
219 <        throws java.io.IOException{
219 >        throws java.io.IOException {
220          s.defaultWriteObject();
221  
222          s.writeDouble(get());
# Line 253 | Line 253 | public class AtomicDouble extends Number
253      private static sun.misc.Unsafe getUnsafe() {
254          try {
255              return sun.misc.Unsafe.getUnsafe();
256 <        } catch (SecurityException se) {
257 <            try {
258 <                return java.security.AccessController.doPrivileged
259 <                    (new java.security
260 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
261 <                        public sun.misc.Unsafe run() throws Exception {
262 <                            java.lang.reflect.Field f = sun.misc
263 <                                .Unsafe.class.getDeclaredField("theUnsafe");
264 <                            f.setAccessible(true);
265 <                            return (sun.misc.Unsafe) f.get(null);
266 <                        }});
267 <            } catch (java.security.PrivilegedActionException e) {
268 <                throw new RuntimeException("Could not initialize intrinsics",
269 <                                           e.getCause());
270 <            }
256 >        } catch (SecurityException tryReflectionInstead) {}
257 >        try {
258 >            return java.security.AccessController.doPrivileged
259 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
260 >                public sun.misc.Unsafe run() throws Exception {
261 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
262 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
263 >                        f.setAccessible(true);
264 >                        Object x = f.get(null);
265 >                        if (k.isInstance(x))
266 >                            return k.cast(x);
267 >                    }
268 >                    throw new NoSuchFieldError("the Unsafe");
269 >                }});
270 >        } catch (java.security.PrivilegedActionException e) {
271 >            throw new RuntimeException("Could not initialize intrinsics",
272 >                                       e.getCause());
273          }
274      }
275   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines