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 bug when shading ScalaLongSignature #10

Merged
merged 1 commit into from
Mar 27, 2021
Merged

Conversation

jamiees2
Copy link
Contributor

@jamiees2 jamiees2 commented Mar 27, 2021

When shading a @ScalaLongSignature(bytes = Array()), ASM calls visit() for each item in the bytes array, and then calls visitEnd() for each time visit() was called as well.

In visitEnd() we write the rewritten ScalaLongSignature completely, so this causes jarjar-abrams to write the ScalaLongSignature multiple times.

When reflecting on one of these classes, we get an error:

java.lang.annotation.AnnotationFormatError: Duplicate annotation for class: interface scala.reflect.ScalaLongSignature: @scala.reflect.ScalaLongSignature(

A decompilation of the affected class shows that the class is annotated multiple times with @scala.reflect.ScalaLongSignature .

This fixes the issue by making sure we only call rewriteAnnotation once for the lifetime of the class. I tested this, and it solved the issue :)

I imagine the issue wasn't caught earlier because running into this requires you to reflect/use typetags on very very large scala classes which have been rewritten by jarjar-abrams, which is likely rare.

Copy link
Owner

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eed3si9n eed3si9n merged commit 879844b into eed3si9n:master Mar 27, 2021
@jamiees2
Copy link
Contributor Author

When possible, could you release a new version to Maven which I can rebuild https://github.com/jamiees2/jarjar-abrams-cli off of? :)

@eed3si9n
Copy link
Owner

https://github.com/eed3si9n/jarjar-abrams/releases/tag/v0.3.1 is on its way to Maven Central

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.

2 participants