6 |
|
|
7 |
|
package java.util.concurrent; |
8 |
|
|
9 |
< |
import java.lang.invoke.MethodHandles; |
10 |
< |
import java.lang.invoke.VarHandle; |
9 |
> |
import java.lang.reflect.Field; |
10 |
|
import java.util.AbstractSet; |
11 |
|
import java.util.Collection; |
12 |
|
import java.util.Collections; |
476 |
|
: ((ConcurrentSkipListMap.SubMap<E,?>)m).new SubMapKeyIterator(); |
477 |
|
} |
478 |
|
|
479 |
< |
// Support for resetting map in clone |
479 |
> |
/** Initializes map field; for use in clone. */ |
480 |
|
private void setMap(ConcurrentNavigableMap<E,Object> map) { |
481 |
< |
MAP.setVolatile(this, map); |
482 |
< |
} |
483 |
< |
|
484 |
< |
// VarHandle mechanics |
485 |
< |
private static final VarHandle MAP; |
486 |
< |
static { |
481 |
> |
Field mapField = java.security.AccessController.doPrivileged( |
482 |
> |
(java.security.PrivilegedAction<Field>) () -> { |
483 |
> |
try { |
484 |
> |
Field f = ConcurrentSkipListSet.class |
485 |
> |
.getDeclaredField("m"); |
486 |
> |
f.setAccessible(true); |
487 |
> |
return f; |
488 |
> |
} catch (ReflectiveOperationException e) { |
489 |
> |
throw new Error(e); |
490 |
> |
}}); |
491 |
|
try { |
492 |
< |
MethodHandles.Lookup l = MethodHandles.lookup(); |
493 |
< |
MAP = l.findVarHandle(ConcurrentSkipListSet.class, "m", |
491 |
< |
ConcurrentNavigableMap.class); |
492 |
< |
} catch (ReflectiveOperationException e) { |
492 |
> |
mapField.set(this, map); |
493 |
> |
} catch (IllegalAccessException e) { |
494 |
|
throw new Error(e); |
495 |
|
} |
496 |
|
} |