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

Comparing jsr166/src/jsr166y/ConcurrentLinkedDeque.java (file contents):
Revision 1.1 by dl, Tue May 24 23:07:32 2011 UTC vs.
Revision 1.6 by jsr166, Sun Jan 13 18:03:32 2013 UTC

# Line 61 | Line 61 | import java.util.Queue;
61   * @author Martin Buchholz
62   * @param <E> the type of elements held in this collection
63   */
64
64   public class ConcurrentLinkedDeque<E>
65      extends AbstractCollection<E>
66      implements Deque<E>, java.io.Serializable {
# Line 306 | Line 305 | public class ConcurrentLinkedDeque<E>
305          static {
306              try {
307                  UNSAFE = getUnsafe();
308 <                Class k = Node.class;
308 >                Class<?> k = Node.class;
309                  prevOffset = UNSAFE.objectFieldOffset
310                      (k.getDeclaredField("prev"));
311                  itemOffset = UNSAFE.objectFieldOffset
# Line 788 | Line 787 | public class ConcurrentLinkedDeque<E>
787       * Creates an array list and fills it with elements of this list.
788       * Used by toArray.
789       *
790 <     * @return the arrayList
790 >     * @return the array list
791       */
792      private ArrayList<E> toArrayList() {
793          ArrayList<E> list = new ArrayList<E>();
# Line 1221 | Line 1220 | public class ConcurrentLinkedDeque<E>
1220       * The following code can be used to dump the deque into a newly
1221       * allocated array of {@code String}:
1222       *
1223 <     * <pre>
1225 <     *     String[] y = x.toArray(new String[0]);</pre>
1223 >     *  <pre> {@code String[] y = x.toArray(new String[0]);}</pre>
1224       *
1225       * Note that {@code toArray(new Object[0])} is identical in function to
1226       * {@code toArray()}.
# Line 1428 | Line 1426 | public class ConcurrentLinkedDeque<E>
1426          NEXT_TERMINATOR.prev = NEXT_TERMINATOR;
1427          try {
1428              UNSAFE = getUnsafe();
1429 <            Class k = ConcurrentLinkedDeque.class;
1429 >            Class<?> k = ConcurrentLinkedDeque.class;
1430              headOffset = UNSAFE.objectFieldOffset
1431                  (k.getDeclaredField("head"));
1432              tailOffset = UNSAFE.objectFieldOffset
# Line 1448 | Line 1446 | public class ConcurrentLinkedDeque<E>
1446      static sun.misc.Unsafe getUnsafe() {
1447          try {
1448              return sun.misc.Unsafe.getUnsafe();
1449 <        } catch (SecurityException se) {
1450 <            try {
1451 <                return java.security.AccessController.doPrivileged
1452 <                    (new java.security
1453 <                     .PrivilegedExceptionAction<sun.misc.Unsafe>() {
1454 <                        public sun.misc.Unsafe run() throws Exception {
1455 <                            java.lang.reflect.Field f = sun.misc
1456 <                                .Unsafe.class.getDeclaredField("theUnsafe");
1457 <                            f.setAccessible(true);
1458 <                            return (sun.misc.Unsafe) f.get(null);
1459 <                        }});
1460 <            } catch (java.security.PrivilegedActionException e) {
1461 <                throw new RuntimeException("Could not initialize intrinsics",
1462 <                                           e.getCause());
1463 <            }
1449 >        } catch (SecurityException tryReflectionInstead) {}
1450 >        try {
1451 >            return java.security.AccessController.doPrivileged
1452 >            (new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() {
1453 >                public sun.misc.Unsafe run() throws Exception {
1454 >                    Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
1455 >                    for (java.lang.reflect.Field f : k.getDeclaredFields()) {
1456 >                        f.setAccessible(true);
1457 >                        Object x = f.get(null);
1458 >                        if (k.isInstance(x))
1459 >                            return k.cast(x);
1460 >                    }
1461 >                    throw new NoSuchFieldError("the Unsafe");
1462 >                }});
1463 >        } catch (java.security.PrivilegedActionException e) {
1464 >            throw new RuntimeException("Could not initialize intrinsics",
1465 >                                       e.getCause());
1466          }
1467      }
1468
1468   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines