Reputation: 984
Is it an Error? I would at least expect an Exception instead of empty String for:
jshell> ((Supplier<String>)(()->StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass().getName())).get()+"invisible";
$1 ==> ""
using jshell 13.0.1
Upvotes: 1
Views: 55
Reputation: 36
I have no explanation, but it seems to be due to some weird behavior of the shell feedback.
jshell> String a = ((Supplier<String>)(() -> StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass().getName())).get();
a ==> ""
jshell> System.out.println(a);
REPL.$JShell$11
jshell> "$JShell$foobar"
$3 ==> ""
JShell seems to interprete the String $Jshell$... somehow, but the String itself is just fine.
Upvotes: 2