On Tue, 6 Sep 2022 16:47:03 GMT, Ioi Lam <ik...@openjdk.org> wrote: > Have you tested with method references? Two references to the same method > will result in a single `JVM_CONSTANT_InvokeDynamic` constant pool entry in > the classfile, but it's invoked by two callsites. As a result, two different > lambda proxy classes will be generated, as the JVMS requires the > invokedynamic resolution to be per callsite, not per constantpool entry. > > ``` > public class ShareBSM { > public static void main(String args[]) { > doit1(ShareBSM::func); > doit2(ShareBSM::func); > } > static void func() { Thread.dumpStack(); } > static void doit1(Runnable r) { r.run(); } > static void doit2(Runnable r) { r.run(); } > } > ``` > > Here's the output: > > ``` > $ java -cp . -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames ShareBSM > java.lang.Exception: Stack trace > at java.base/java.lang.Thread.dumpStack(Thread.java:1380) > at ShareBSM.func(ShareBSM.java:8) > at ShareBSM$$Lambda$1/0x0000000800c009f0.run(Unknown Source) > at ShareBSM.doit1(ShareBSM.java:12) > at ShareBSM.main(ShareBSM.java:3) > java.lang.Exception: Stack trace > at java.base/java.lang.Thread.dumpStack(Thread.java:1380) > at ShareBSM.func(ShareBSM.java:8) > at ShareBSM$$Lambda$2/0x0000000800c00bf8.run(Unknown Source) > at ShareBSM.doit2(ShareBSM.java:15) > at ShareBSM.main(ShareBSM.java:4) > ``` > > Will you patch generate the same name for both callsites? Does this matter > for your use case?
@iklam Yes, I tested it against method references too. The patch produces the same names as it should. I enhanced the test with one additional method that will explicitly use method references. We don't want confusion about this in the future. ------------- PR: https://git.openjdk.org/jdk/pull/10024