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 { |
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 |
|
} |
1467 |
– |
|
1468 |
|
} |