Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use LambdaMetafactory to generate Supplier<Checksum> for java.util.zip.CRC32C instances #595

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

bokken
Copy link
Contributor

@bokken bokken commented Aug 28, 2024

currently we have written a lambda (turns into anonymous class) which invokes a MethodHandle for the java.util.zip.CRC32C constructor as the Supplier implementation.

This has 2 layers of misdirection. The Supplier implementation spun up by the jvm calls the anonymous lambda class, which then calls the MethodHandle invoke. This leads to stack traces like:

	CRC32C.<init>() line: 126	
	DirectMethodHandle$Holder.newInvokeSpecial(Object) line: not available	
	Invokers$Holder.invokeExact_MT(Object, Object) line: not available	
	SnappyFramed.lambda$0(MethodHandle) line: 48	
	0x0000027d6201b320.get() line: not available	
	SnappyFramed.getCRC32C() line: 76	

We can use LambdaMetafactory to generate a Supplier which calls the java.util.zip.CRC32C constructor directly. This results in a single layer of misdirection:

	CRC32C.<init>() line: 126	
	0x000001621601b320.get() line: not available	
	SnappyFramed.getCRC32C() line: 83	

currently we have written a lambda (turns into anonymous class) which
invokes a MethodHandle for the java.util.zip.CRC32C constructor as the
Supplier<Checksum> implementation.

This has 2 layers of misdirection. The Supplier implementation spun up
by the jvm calls the anonymous lambda class, which then calls the
MethodHandle invoke. This leads to stack traces like:

use LambdaMetafactory to generate a Supplier<Checksum> which calls the
java.util.zip.CRC32C
@bokken
Copy link
Contributor Author

bokken commented Sep 4, 2024

@xerial any chance to review?

@xerial
Copy link
Owner

xerial commented Sep 10, 2024

@bokken Thanks for the heads-up. LGTM.

@xerial xerial merged commit 01368fe into xerial:master Sep 10, 2024
7 checks passed
@bokken bokken deleted the lambda branch October 5, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants