ppkarwasz opened a new issue, #4007:
URL: https://github.com/apache/logging-log4j2/issues/4007
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`](https://logging.apache.org/log4j/2.x/javadoc/log4j-api/org/apache/logging/log4j/util/PropertiesUtil.html)),
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:
```text
> 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:
1. **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.
2. **Disable the `classfile` lint category** by adding `-Xlint:-classfile`.
This category rarely provides actionable information and is the root
cause of the failure here. See
[https://github.com/apache/logging-log4j2/issues/3110#issuecomment-2423586754](https://github.com/apache/logging-log4j2/issues/3110#issuecomment-2423586754)
for additional context.
3. **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 is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]