Fix shaded Guava annotation refs breaking -Xlint:classfile consumers - #4437
Open
kalayciburak wants to merge 1 commit into
Open
Fix shaded Guava annotation refs breaking -Xlint:classfile consumers#4437kalayciburak wants to merge 1 commit into
kalayciburak wants to merge 1 commit into
Conversation
Relocate and ship Guava annotation packages (common.annotations, errorprone, j2objc, checker-qual, jsr305) with the minimized Guava shade so RuntimeInvisibleAnnotations on ImmutableList and friends no longer point at types absent from the published jar. Consumers compiling with -Xlint:classfile -Werror (e.g. Spring for GraphQL) failed on those dangling descriptors. Add a packaging check and Spock guard for the published jar. Fixes graphql-java#4436 Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
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.
Summary
Fixes #4436.
The published jar shades a minimized subset of Guava under
graphql.com.google.common, but classfiles such asImmutableListkeepRuntimeInvisibleAnnotationsthat reference annotation types that were never included:com.google.common.annotations.GwtCompatible(and related)com.google.errorprone.annotations.DoNotCall/InlineMe/ …com.google.j2objc.annotations.*org.checkerframework.*javax.annotation.*Consumers that compile with
-Xlint:classfile -Werror(reported from Spring for GraphQL against 26.0) fail withCannot find annotation method … class file for … not found.Change
shadowJar(withminimizeexcludes so they are retained).Import-Packagefrom re-exporting the shaded packages.verifyShadedJarAnnotationRefs(wired intocheck/ afterbuildNewJar) andShadedJarAnnotationRefsTestso a regression fails the packaging pipeline.Test plan
Executed locally:
javac --release 17 -Xlint:classfile -Werror -cp <published-jar> …againstgraphql.com.google.common.collect.ImmutableListfailed with missingGwtCompatible/DoNotCall/InlineMeclassfilesexit 0)./gradlew shadowJar verifyShadedJarAnnotationRefsSUCCESS./gradlew test --tests graphql.ShadedJarAnnotationRefsTest --tests graphql.GuavaLimitCheck --tests 'graphql.collect.*' --tests 'graphql.relay.*'— 38 tests GREEN