Repository navigation
Shaded google dependency points to dangling annotation references #4436
Description
Hi team,
I have been running Spring for GraphQL tests against GraphQL Java 26.0 for a while now.
But as I'm preparing for the next minor version, I am trying to compile the project against 26.0 and getting compiler warnings like this.
:spring-graphql:compileJava FAILED
/Users/bclozel/.gradle/caches/modules-2/files-2.1/com.graphql-java/graphql-java/26.0/d1a1d3005ca6f4a87b4a985a1907b22bf5b63700/graphql-java-26.0.jar(/graphql/com/google/common/collect/ImmutableList.class): warning: [classfile] Cannot find annotation method 'serializable()' in type 'GwtCompatible': class file for com.google.common.annotations.GwtCompatible not found
/Users/bclozel/.gradle/caches/modules-2/files-2.1/com.graphql-java/graphql-java/26.0/d1a1d3005ca6f4a87b4a985a1907b22bf5b63700/graphql-java-26.0.jar(/graphql/com/google/common/collect/ImmutableList.class): warning: [classfile] Cannot find annotation method 'emulated()' in type 'GwtCompatible'
/Users/bclozel/.gradle/caches/modules-2/files-2.1/com.graphql-java/graphql-java/26.0/d1a1d3005ca6f4a87b4a985a1907b22bf5b63700/graphql-java-26.0.jar(/graphql/com/google/common/collect/ImmutableList.class): warning: [classfile] Cannot find annotation method 'value()' in type 'DoNotCall': class file for com.google.errorprone.annotations.DoNotCall not found
/Users/bclozel/.gradle/caches/modules-2/files-2.1/com.graphql-java/graphql-java/26.0/d1a1d3005ca6f4a87b4a985a1907b22bf5b63700/graphql-java-26.0.jar(/graphql/com/google/common/collect/ImmutableList.class): warning: [classfile] Cannot find annotation method 'value()' in type 'DoNotCall'
/Users/bclozel/.gradle/caches/modules-2/files-2.1/com.graphql-java/graphql-java/26.0/d1a1d3005ca6f4a87b4a985a1907b22bf5b63700/graphql-java-26.0.jar(/graphql/com/google/common/collect/ImmutableList.class): warning: [classfile] Cannot find annotation method 'value()' in type 'DoNotCall'
/Users/bclozel/.gradle/caches/modules-2/files-2.1/com.graphql-java/graphql-java/26.0/d1a1d3005ca6f4a87b4a985a1907b22bf5b63700/graphql-java-26.0.jar(/graphql/com/google/common/collect/ImmutableList.class): warning: [classfile] Cannot find annotation method 'value()' in type 'DoNotCall'
/Users/bclozel/.gradle/caches/modules-2/files-2.1/com.graphql-java/graphql-java/26.0/d1a1d3005ca6f4a87b4a985a1907b22bf5b63700/graphql-java-26.0.jar(/graphql/com/google/common/collect/ImmutableList.class): warning: [classfile] Cannot find annotation method 'value()' in type 'DoNotCall'
/Users/bclozel/.gradle/caches/modules-2/files-2.1/com.graphql-java/graphql-java/26.0/d1a1d3005ca6f4a87b4a985a1907b22bf5b63700/graphql-java-26.0.jar(/graphql/com/google/common/collect/ImmutableList.class): warning: [classfile] Cannot find annotation method 'value()' in type 'DoNotCall'
/Users/bclozel/.gradle/caches/modules-2/files-2.1/com.graphql-java/graphql-java/26.0/d1a1d3005ca6f4a87b4a985a1907b22bf5b63700/graphql-java-26.0.jar(/graphql/com/google/common/collect/ImmutableList.class): warning: [classfile] Cannot find annotation method 'replacement()' in type 'InlineMe': class file for com.google.errorprone.annotations.InlineMe not found
error: warnings found and -Werror specified
This is breaking my build since it's compiling with javac -Xlint:classfile -Werror
It looks like 26.0 shades relocated Guava classes (like graphql.com.google.common.collect.ImmutableList) whose bytecode still carries RuntimeInvisibleAnnotations referencing the original relocated annotation
types:
com.google.common.annotations.GwtCompatiblecom.google.errorprone.annotations.DoNotCallcom.google.errorprone.annotations.InlineMe
Those classes are not present in the jar and this causes the compiler issues.
You can reproduce this with a minimal build like and run compileJava:
dependencies {
implementation 'com.graphql-java:graphql-java:26.0'
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ['-Xlint:classfile', '-Werror']
}I can't reproduce this with 25.0, but I'm not sure when/how this was introduced.
I guess the shadowJar task configuration must be updated to avoid such problems.
Activity
bclozel commentedon Aug 19, 2026
I spent a bit more time looking into this problem.
Annotations that are
RuntimeInvisibleAnnotationsare indeed not used or read at runtime, but the java compiler reads those when it loads the class at compile time. Here,@GwtCompatible,@DoNotCalland others are used for static analysis and are not read at runtime. If one of those annotations is missing at compile time, the compiler can't fully resolve it and we get a compiler warning.It seems that the shadowing configuration didn't change, and the guava version isn't responsible either. In fact, it seems that this problem has been around for long and only materialized recently because of other code changes.
I have found two changes that might explain that
ImmutableListis now more broadly exposed to consumers (whereas before this was kept private within implementations):ImmutableListon public methods in the execution packageSo to summarize, this is not a new problem but this was exposed more broadly in 26.0. The very nature of guava types makes them hard to contain: even if you adopt an architecture rule that prevents them from being exposed on public signatures, they might appear at compile time through lambdas and other language constructs.
bclozel commentedon Aug 20, 2026
This has been fixed by #4445.