From c9c3de059e3079bcf0e0cc812b98c7cb5a534226 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Wed, 18 Jun 2025 21:08:08 +0200 Subject: [PATCH] Upgrade Log4j and Harden Annotation Processing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR makes the following changes: * Upgrades Log4j to version `2.25.0`. * Hardens annotation processing in response to the [JDK 23 change in default annotation processing policy](https://inside.java/2024/06/18/quality-heads-up/), which deprecates implicit annotation processor discovery. This change has been backported to earlier JDKs as well. ### Key Improvements: * Annotation processing is now disabled by default (`none`) to ensure only explicitly declared processors are run — a best practice that improves build predictability and mitigates supply chain risks ([background](https://javapro.io/2024/11/19/discovering-the-perfect-java-supply-chain-attack-vector-and-how-it-got-fixed/)). * The `pdfbox-debugger` module is now explicitly compiled using: * `PluginProcessor` to generate the `Log4j2Plugins.dat` descriptor. * The new `GraalVmProcessor` to generate GraalVM reachability metadata. * Both processors are declared explicitly along with the required compiler arguments: ```text -Alog4j.graalvm.groupId=${project.groupId} -Alog4j.graalvm.artifactId=${project.artifactId} ``` This avoids build failures introduced by `GraalVmProcessor` when those parameters are missing. ### Why This Matters: Log4j 2.25.0 introduces stricter behavior for `GraalVmProcessor`, which fails with an error if required options aren't set. Combined with changes to how annotation processors are discovered in JDK 23+, these updates ensure that: * Build behavior is explicit and secure. * The `DebugLogAppender` remains compatible with ahead-of-time compilation tools like GraalVM. * The project is future-proofed against evolving Java defaults and security posture. --- debugger/pom.xml | 40 ++++++++++++++++++++++++++++++++++++++++ parent/pom.xml | 4 +++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/debugger/pom.xml b/debugger/pom.xml index 9edfaa35014..1365b1b9bd7 100644 --- a/debugger/pom.xml +++ b/debugger/pom.xml @@ -97,6 +97,46 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + + + default-compile + + + full + + + org.apache.logging.log4j + log4j-core + + + + + + org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor + + + + org.apache.logging.log4j.core.config.plugins.processor.GraalVmProcessor + + + + + -Alog4j.graalvm.groupId=${project.groupId} + -Alog4j.graalvm.artifactId=${project.artifactId} + + + + + org.apache.maven.plugins maven-jar-plugin diff --git a/parent/pom.xml b/parent/pom.xml index 9038a56fddd..4239504c686 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -56,7 +56,7 @@ UTF-8 1.81 - 2.24.3 + 2.25.0 5.13.1 3.0.4 1.4.0 @@ -160,6 +160,8 @@ true UTF-8 + + none