You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is a continuation of the long-running -Werror -Xlint:all saga.
When all of the following apply:
the build uses Gradle,
the compiler is JDK 8 through 16,
compilation is run with -Werror -Xlint:all,
the code references a Log4j API class annotated with a biz.aQute.bnd.annotation
(for example PropertiesUtil),
the build fails with a compiler warning promoted to an error.
The failure is caused by a bytecode-level mismatch: Log4j 2.25.3 exposes biz.aQute.bnd.annotation:7.1.0 via Gradle Module Metadata, but that artifact is built for Java 17 (class file version 61) and is therefore incompatible with JDK 8/11 compilers when -Xlint:classfile is enabled.
Example failure:
> Task :compileJava FAILED
.../log4j-api-2.25.3.jar(org/apache/logging/log4j/util/ProviderUtil.class): warning:
Cannot find annotation method 'value()' in type 'aQute.bnd.annotation.spi.ServiceConsumer':
bad class file:
.../biz.aQute.bnd.annotation-7.1.0.jar(aQute/bnd/annotation/spi/ServiceConsumer.class)
class has wrong version 61.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
Workarounds
Several workarounds are available:
Use a newer JDK to compile the project.
Even recent JDKs (including JDK 25) can still target Java 8 bytecode via --release. The JDK used for compilation does not dictate the output bytecode level.
Force a compatible annotation version by adding biz.aQute.bnd.annotation:6.4.1 to the application’s compileOnly configuration and enforcing that version in Gradle resolution.
Planned fix
This will be addressed in a future Log4j API release by downgrading the exported biz.aQute.bnd.annotation version to 6.4.1 in the Gradle Module Metadata (via the Gradle Module Metadata Maven Plugin), ensuring compatibility with Java 8 and Java 11 consumers.
This issue is a continuation of the long-running
-Werror -Xlint:allsaga.When all of the following apply:
-Werror -Xlint:all,biz.aQute.bnd.annotation(for example
PropertiesUtil),the build fails with a compiler warning promoted to an error.
The failure is caused by a bytecode-level mismatch: Log4j
2.25.3exposesbiz.aQute.bnd.annotation:7.1.0via Gradle Module Metadata, but that artifact is built for Java 17 (class file version 61) and is therefore incompatible with JDK 8/11 compilers when-Xlint:classfileis enabled.Example failure:
Workarounds
Several workarounds are available:
Use a newer JDK to compile the project.
Even recent JDKs (including JDK 25) can still target Java 8 bytecode via
--release. The JDK used for compilation does not dictate the output bytecode level.Disable the
classfilelint category by adding-Xlint:-classfile.This category rarely provides actionable information and is the root cause of the failure here. See
Upgrading to 2.24.1 produces a compile time warning: BaselineIgnore not found #3110 (comment) for additional context.
Force a compatible annotation version by adding
biz.aQute.bnd.annotation:6.4.1to the application’scompileOnlyconfiguration and enforcing that version in Gradle resolution.Planned fix
This will be addressed in a future Log4j API release by downgrading the exported
biz.aQute.bnd.annotationversion to6.4.1in the Gradle Module Metadata (via the Gradle Module Metadata Maven Plugin), ensuring compatibility with Java 8 and Java 11 consumers.