Having this code (complete test case attached):
public static Function<Integer, Integer> fi;
public static void getLambda() {
int one = 1;
fi = x -> x + one;
}
Compiling and disassembling with the latest hotspot-comp/Linux x86_64 produces the following part of the code:
0x00007fbf60247b12: mov $0xefe4c046,%r10d ; {metadata('Test$$Lambda$1')}
0x00007fbf60247b18: movzbl 0x186(%r12,%r10,8),%r11d
0x00007fbf60247b21: add $0xfffffffffffffffc,%r11d
0x00007fbf60247b25: test %r11d,%r11d
0x00007fbf60247b28: jne 0x00007fbf60247b3f
This is class initialization check, generated because of LambdaForm jsr292 implementation uses Unsafe.allocateInstance for lambda instance creation.
According to how lambdas are generated - this check is redundant.
public static Function<Integer, Integer> fi;
public static void getLambda() {
int one = 1;
fi = x -> x + one;
}
Compiling and disassembling with the latest hotspot-comp/Linux x86_64 produces the following part of the code:
0x00007fbf60247b12: mov $0xefe4c046,%r10d ; {metadata('Test$$Lambda$1')}
0x00007fbf60247b18: movzbl 0x186(%r12,%r10,8),%r11d
0x00007fbf60247b21: add $0xfffffffffffffffc,%r11d
0x00007fbf60247b25: test %r11d,%r11d
0x00007fbf60247b28: jne 0x00007fbf60247b3f
This is class initialization check, generated because of LambdaForm jsr292 implementation uses Unsafe.allocateInstance for lambda instance creation.
According to how lambdas are generated - this check is redundant.
- duplicates
-
JDK-8022675 Redundant class init check
-
- Resolved
-