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

Fix removal of SneakyThrows and PreventNullAnalysis from bytecode #3602

Conversation

oleludwig
Copy link
Contributor

The SneakyThrowsRemover and PreventNullAnalysisRemover were leaving traces of the calls to lombok.Lombok.sneakyThrow and lombok.Lombok.preventNullAnalysis behind because they were using a constructor of ClassWriter which reuses the constant pool of the original class for performance optimizations. So although the calls to sneakyThrows and preventNullAnalysis get removed from the methods there were still entries in the constant pool for them. The constant pool will be regenerated with this change so that the entries for sneakyThrows and preventNullAnalysis gets removed.

Relevant javadoc of the ClassWriter contructor: https://asm.ow2.io/javadoc/org/objectweb/asm/ClassWriter.html#%3Cinit%3E(org.objectweb.asm.ClassReader,int)

Fixes #3601

The SneakyThrowsRemover and PreventNullAnalysisRemover were leaving traces of the calls to lombok.Lombok.sneakyThrow and lombok.Lombok.preventNullAnalysis behind because they were using a constructor of ClassWriter which reuses the constant pool of the original class for performance optimizations.
So although the calls to sneakyThrows and preventNullAnalysis get removed from the methods there were still entries in the constant pool for them.
The constant pool will be regenerated with this change so that the entries for sneakyThrows and preventNullAnalysis gets removed.
@Rawi01
Copy link
Collaborator

Rawi01 commented Feb 7, 2024

Excellent work, thanks for the PR!

Can you please add yourself to the AUTHORS file.

@oleludwig
Copy link
Contributor Author

Thanks for the review @Rawi01. I added myself to the AUTHORS file and updated the PR.

@Rawi01 Rawi01 merged commit 8bea251 into projectlombok:master Feb 7, 2024
@rspilker
Copy link
Collaborator

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] SneakyThrows leaves traces to lombok in the class files
3 participants