Skip to content

Commit

Permalink
Java 24 in core profile fails with java.lang.UnsupportedOperationExce…
Browse files Browse the repository at this point in the history
…ption: No access to RETAIN_CLASS_REFERENCE #1735 (#1736)

Signed-off-by: Jorge Bescos Gascon <[email protected]>
  • Loading branch information
jbescos authored Jan 9, 2025
1 parent 4228fdd commit 9597841
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) "2022" Red Hat and others
* Copyright (c) "2022", "2025" Red Hat and others
*
* This program and the accompanying materials are made available under the
* Apache Software License 2.0 which is available at:
Expand All @@ -17,15 +17,19 @@
public class Utils {
private static final Stack<String> callStack = new Stack<>();
public static void pushMethod() {
StackWalker walker = StackWalker.getInstance();
StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
Optional<String> methodName = walker.walk(frames -> frames
.skip(1)
.findFirst()
.map(Utils::getMethodInfo));
callStack.push(methodName.get());
}
private static String getMethodInfo(StackWalker.StackFrame frame) {
return frame.getMethodName() + frame.getDescriptor();
try {
return frame.getMethodName() + frame.getDescriptor();
} catch (Exception e) {
throw new IllegalArgumentException("Cannot access frame: " + frame, e);
}
}
public static String popStack() {
return callStack.pop();
Expand Down

0 comments on commit 9597841

Please sign in to comment.