Log4j pollutes downstream compile classpaths, for example making compilation slower

オープン
#4,034 コメント 9 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@ppkarwasz がすでに取り組んでいます。

2026年3月16日 から。

評価

この issue はまだ評価されていません。

説明

bug build dependencies priority: P2

Description

Log4j since version 2.25 publishes Gradle Module Metadata.

In the Gradle Module Metadata it declares dependencies on 5 libraries that only contain annotations and that are only used to annotate code, not anywhere in the API.

These dependencies should not be exposed in the apiElements variant as that just pollutes the downstream compile classpaths.

Annotations for which no classfile is present are ignored by the JVM.

If someone wants to use those annotations, that someone is responsible to add the annotation to the classpath.

If this was added to work-around the problem that you get a warning (and with -Werror an error) from the Java compiler about missing class files for enum constants used in annotations, this is a bug in the Java compiler (https://bugs.openjdk.org/browse/JDK-8305250) and should imho not be worked-around on the library-level.

As you can for example read at https://mail.openjdk.org/pipermail/jdk-dev/2024-October/009459.html and https://bugs.openjdk.org/browse/JDK-6322301, annotations for which no classfile is present should be ignored by the JVM.

This should be fixed by fixing the bug in javac.
As work-around on the client side, one could stop using -Werror, disable that specific linting option, or add the dependencies in question to the compileOnly configuration.

It is imho not the responsibility of a library to work-around this bug in Javac that is used by downstream projects with special configuration, thereby polluting the compile classpath of all downstream projects even if they don't use that option that makes the warning an error and thus making compilation slower for all downstream projects unless they then manually exclude those dependencies.

Configuration

Version: 2.25+

主要言語
Java
スター
3.6k
フォーク
1.8k
平均マージ
5日 6時間
マージ済み PR(30日)
24

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/logging-log4j2 のほかの issue

apache/logging-log4j2 の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。