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

Jarjar shouldn't mangle classes when no meaningful transformation applied #52

Merged
merged 3 commits into from
Feb 5, 2024

Conversation

cdkrot
Copy link
Contributor

@cdkrot cdkrot commented Jan 27, 2024

In case big module and all it dependent jars are going through jarjar shading, there will probably be dependent jars which are not actually modified by shading.

However because they go through jarjar, it unpacks, revisits, and repacks the class back resulting a technically different class from before shading (even class size can be different from original). This upsets classpath checkers (i.e. checking that runtime classpath has at most 1 unique class version).

I propose to add a change so that jarjar can detect whether the meaningful transformation to class file has happened and if not, the class is unmodified.

This pull request introduces following new concepts:

  • TracingRemapper: extension of Remapper with capability of tracking if the change was applied;
  • RemappingJarProcessor: extension of JarProcessor focusing on TracingRemapper-based processors. It assumes ownership of TracingRemapper, and will verify if the mentioned remapper did any transformation.

The existing classes change as follows:

  • PackageRemapper: becomes instance of TracingRemapper.
  • JarTransformer, MethodSignatureProcessor: become instance of RemappingJarProcessor.
  • JarTransformerChain: instead of being stateful class keeping track of parent visitors, becomes stateless class. This potentially allows multi-threaded processing and better design overall.

Added coverage for the proposed new functionality in UnmodifiedTest.

Closes: #47

@eed3si9n
Copy link
Owner

Could you run scalafmt plz?

[warn] /home/runner/work/jarjar-abrams/jarjar-abrams/core/src/main/scala/com/eed3si9n/jarjar/JJProcessor.scala isn't formatted properly!
[error] 1 files must be formatted
[error] (core / Compile / scalafmtCheck) 1 files must be formatted

@cdkrot
Copy link
Contributor Author

cdkrot commented Jan 28, 2024

Thanks! I think I did now

@eed3si9n eed3si9n merged commit ad175de into eed3si9n:develop Feb 5, 2024
4 checks passed
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.

Jarjar mangles classes even when no meaningful transformation applied
2 participants