Do not write modified class files for no-op relocations#1694
Merged
Goooler merged 2 commits intoGradleUp:mainfrom Aug 28, 2025
Merged
Conversation
e3470bb to
a5e7270
Compare
Goooler
reviewed
Aug 27, 2025
src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/BasePluginTest.kt
Outdated
Show resolved
Hide resolved
src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt
Outdated
Show resolved
Hide resolved
src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt
Outdated
Show resolved
Hide resolved
a5e7270 to
ccb676d
Compare
If we don't need to make any changes to the class, we should use the original bytes instead of letting ASM generate new ones. Some tools use class file bytes to determine if there are classpath conflicts, and the current approach leads to false positives.
ccb676d to
21a9483
Compare
Goooler
reviewed
Aug 28, 2025
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt
Outdated
Show resolved
Hide resolved
Goooler
approved these changes
Aug 28, 2025
7c551b4 to
cdf1e90
Compare
cdf1e90 to
fbd5957
Compare
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If we don't need to make any changes to the class, we should use the original bytes instead of letting ASM generate new ones.
Some tools (e.g. https://plugins.gradle.org/plugin/com.palantir.baseline-class-uniqueness) use (hashes of) class file bytes to determine if there are classpath conflicts, and Shadow's current logic causes false positives.
But even in general, I believe it makes sense to change as little as we can.
A similar change was made to the maven shade plugin at apache/maven-shade-plugin#95.