-
Notifications
You must be signed in to change notification settings - Fork 131
Open
Description
SecurityManager is deprecated for removal, see also https://openjdk.org/jeps/486
It is used in procyon in CallerResolver for SecurityManager#getClassContext:
That use-case could be migrated to java.lang.StackWalker, with something like:
public final class CallerResolver {
private static final StackWalker STACK_WALKER =
StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
private static final int CALL_CONTEXT_OFFSET = 1; // may need to change if this class is redesigned
/**
* Indexes into the current method call context with a given offset.
*/
public static Class getCallerClass(final int callerOffset) {
return STACK_WALKER
.walk(
s -> s.skip(CALL_CONTEXT_OFFSET + callerOffset)
.map(StackWalker.StackFrame::getDeclaringClass)
.findFirst())
.get();
}
}The StackWalker API was added in Java 9, and I think procyon is compatible with JDK 7. To migrate while continuing to support JDK 7 it would be possible to use reflection to access StackWalker, or a multi-release jar.
Metadata
Metadata
Assignees
Labels
No labels