8344549: Cleanup AccessController in sun.misc.Unsafe
Reviewed-by: alanb
This commit is contained in:
parent
78e5008e91
commit
191b38e712
@ -31,11 +31,7 @@ import java.lang.foreign.MemorySegment;
|
|||||||
import java.lang.foreign.ValueLayout;
|
import java.lang.foreign.ValueLayout;
|
||||||
import java.lang.invoke.VarHandle;
|
import java.lang.invoke.VarHandle;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.URL;
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.CodeSource;
|
import java.security.CodeSource;
|
||||||
import java.security.ProtectionDomain;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -1829,7 +1825,7 @@ public final class Unsafe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the options for the depreacted method-access methods.
|
* Represents the options for the deprecated method-access methods.
|
||||||
*/
|
*/
|
||||||
private enum MemoryAccessOption {
|
private enum MemoryAccessOption {
|
||||||
/**
|
/**
|
||||||
@ -1881,14 +1877,8 @@ public final class Unsafe {
|
|||||||
* Holder for StackWalker that retains class references.
|
* Holder for StackWalker that retains class references.
|
||||||
*/
|
*/
|
||||||
private static class StackWalkerHolder {
|
private static class StackWalkerHolder {
|
||||||
static final StackWalker INSTANCE;
|
static final StackWalker INSTANCE =
|
||||||
static {
|
StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
|
||||||
PrivilegedAction<StackWalker> pa = () ->
|
|
||||||
StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
StackWalker walker = AccessController.doPrivileged(pa);
|
|
||||||
INSTANCE = walker;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1918,9 +1908,7 @@ public final class Unsafe {
|
|||||||
* Returns a string with the caller class and the location URL from the CodeSource.
|
* Returns a string with the caller class and the location URL from the CodeSource.
|
||||||
*/
|
*/
|
||||||
private static String callerAndLocation(Class<?> callerClass) {
|
private static String callerAndLocation(Class<?> callerClass) {
|
||||||
PrivilegedAction<ProtectionDomain> pa = callerClass::getProtectionDomain;
|
CodeSource cs = callerClass.getProtectionDomain().getCodeSource();
|
||||||
@SuppressWarnings("removal")
|
|
||||||
CodeSource cs = AccessController.doPrivileged(pa).getCodeSource();
|
|
||||||
String who = callerClass.getName();
|
String who = callerClass.getName();
|
||||||
if (cs != null && cs.getLocation() != null) {
|
if (cs != null && cs.getLocation() != null) {
|
||||||
who += " (" + cs.getLocation() + ")";
|
who += " (" + cs.getLocation() + ")";
|
||||||
|
Loading…
Reference in New Issue
Block a user