RFR: 8340852: ScrollPane should not consume navigation keys when it doesn't have direct focus
Andy Goryachev
angorya at openjdk.org
Thu Oct 3 21:05:47 UTC 2024
On Thu, 3 Oct 2024 19:54:58 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> It's an interesting suggestion, but it is not needed. `javac` will already deduplicate these.
>>
>> You can even verify that this is the case. Use `javap` to decompile the class file with `javap -c <classname>`. In there, `invokedynamic` is used to represent the lambda's. It looks like this for example:
>>
>> 120: invokedynamic #54, 0 // InvokeDynamic #1:test:(Lcom/sun/javafx/scene/control/behavior/ScrollPaneBehavior;)Ljava/util/function/Predicate;
>>
>> Later on, you'll see another:
>>
>> 152: invokedynamic #54, 0 // InvokeDynamic #1:test:(Lcom/sun/javafx/scene/control/behavior/ScrollPaneBehavior;)Ljava/util/function/Predicate;
>>
>> What you can see here is that the same constant (# 54) is used to reference the method. So, there's no need to help the compiler here.
>
> hmmm... when I set up a breakpoint in Eclipse in KeyMapping:785 (after it hits the ScrollPaneBehavior<init>) the value for `interceptor` changes
>
>
> interceptor= 0x0000007001340d50 (id=208)
> interceptor= 0x00000070013411c0 (id=212)
> interceptor= 0x0000007001341630 (id=216)
>
>
> I think it's still creates a different lambda object. (I recall testing this assumption with some unit test a while back).
yep, it's a different object. the constant you are referring to is just a name of the method, I think. here:
public class AppTestLauncher {
public static void main(String[] args) throws Throwable {
Runnable a = AppTestLauncher::func;
Runnable b = AppTestLauncher::func;
System.out.println("a=" + a + " b=" + b + " == " + (a == b));
}
static void func() { }
outputs
`a=goryachev.apps.AppTestLauncher$$Lambda/0x000000f801008c78 at 16c0663d b=goryachev.apps.AppTestLauncher$$Lambda/0x000000f801008e90 at 23223dd8 == false
`
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1582#discussion_r1786841867
More information about the openjfx-dev
mailing list