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

Comparing jsr166/src/jsr166e/extra/AtomicDoubleArray.java (file contents):
Revision 1.4 by jsr166, Tue Oct 25 19:21:27 2011 UTC vs.
Revision 1.9 by jsr166, Mon Mar 4 16:09:25 2013 UTC

# Line 14 | Line 14 | import static java.lang.Double.longBitsT
14   * See the {@link java.util.concurrent.atomic} package specification
15   * for description of the properties of atomic variables.
16   *
17 < * <p><a name="bitEquals">This class compares primitive {@code double}
17 > * <p id="bitEquals">This class compares primitive {@code double}
18   * values in methods such as {@link #compareAndSet} by comparing their
19   * bitwise representation using {@link Double#doubleToRawLongBits},
20   * which differs from both the primitive double {@code ==} operator
# Line 162 | Line 162 | public class AtomicDoubleArray implement
162       * if the current value is <a href="#bitEquals">bitwise equal</a>
163       * to the expected value.
164       *
165 <     * <p>May <a
165 >     * <p><a
166       * href="http://download.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/package-summary.html#Spurious">
167 <     * fail spuriously</a>
168 <     * and does not provide ordering guarantees, so is only rarely an
169 <     * appropriate alternative to {@code compareAndSet}.
167 >
168 >     * May fail spuriously and does not provide ordering guarantees</a>,
169 >     * so is only rarely an appropriate alternative to {@code compareAndSet}.
170       *
171       * @param i the index
172       * @param expect the expected value
# Line 242 | Line 242 | public class AtomicDoubleArray implement
242       *             of its elements (each a {@code double}) in the proper order.
243       */
244      private void writeObject(java.io.ObjectOutputStream s)
245 <        throws java.io.IOException{
245 >        throws java.io.IOException {
246          s.defaultWriteObject();
247  
248          // Write out array length
# Line 300 | Line 300 | public class AtomicDoubleArray implement
300      private static sun.misc.Unsafe getUnsafe() {
301          try {
302              return sun.misc.Unsafe.getUnsafe();
303 <        } catch (SecurityException se) {
304 <            try {
305 <                return java.security.AccessController.doPrivileged
306 <                    (new java.security
307 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
308 <                        public sun.misc.Unsafe run() throws Exception {
309 <                            java.lang.reflect.Field f = sun.misc
310 <                                .Unsafe.class.getDeclaredField("theUnsafe");
311 <                            f.setAccessible(true);
312 <                            return (sun.misc.Unsafe) f.get(null);
313 <                        }});
314 <            } catch (java.security.PrivilegedActionException e) {
315 <                throw new RuntimeException("Could not initialize intrinsics",
316 <                                           e.getCause());
317 <            }
303 >        } catch (SecurityException tryReflectionInstead) {}
304 >        try {
305 >            return java.security.AccessController.doPrivileged
306 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
307 >                public sun.misc.Unsafe run() throws Exception {
308 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
309 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
310 >                        f.setAccessible(true);
311 >                        Object x = f.get(null);
312 >                        if (k.isInstance(x))
313 >                            return k.cast(x);
314 >                    }
315 >                    throw new NoSuchFieldError("the Unsafe");
316 >                }});
317 >        } catch (java.security.PrivilegedActionException e) {
318 >            throw new RuntimeException("Could not initialize intrinsics",
319 >                                       e.getCause());
320          }
321      }
322   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines