On Tue, 25 Oct 2022 19:33:25 GMT, Mandy Chung <mch...@openjdk.org> wrote:

>> Ioi Lam has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   @JornVernee comments
>
> src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java line 
> 312:
> 
>> 310:         String callerName = caller.getName();
>> 311:         String[] callerInfo = new String[] {callerName};
>> 312:         StackWalker.getInstance().walk(new 
>> Function<Stream<StackWalker.StackFrame>, Object>() {
> 
> You can call `StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE)` to 
> retain `Class` instance in `StackFrame` such that you can compare `Class` 
> instance rather than class name.

The `StackWalker` API depends on Streams, which is likely to have lambdas in 
its implementation. To avoid the possibility of bootstrap problems, I have 
changed the code to use `Thread.currentThread().getStackTrace()`, which is used 
by `Throwable.printStackTrace()`. Since `printStackTrace()` is supposed to be 
useable at very early bootstrap stages, we are sure no lambdas will be used.

Unfortunately `getStackTrace()` doesn't return the `Class` object, so I have to 
use the class's name.

-------------

PR: https://git.openjdk.org/jdk/pull/10842

Reply via email to