Merge log4j-*-java9 modules into log4j-api and log4j-core - #4260
Open
ppkarwasz wants to merge 1 commit into
Open
Merge log4j-*-java9 modules into log4j-api and log4j-core#4260ppkarwasz wants to merge 1 commit into
log4j-*-java9 modules into log4j-api and log4j-core#4260ppkarwasz wants to merge 1 commit into
Conversation
The `log4j-api-java9` and `log4j-core-java9` modules are a relict from an era where multi-release JAR content could not be produced by the consuming Maven module itself. Each compiled a handful of Java 9 sources (padded with stub classes to satisfy the compiler), zipped them in a `classes/META-INF/versions/9` layout and had the consumer unpack the zip into `target` at `prepare-package`. Compile the Java 9 sources directly in `log4j-api` and `log4j-core` instead, using a second `maven-compiler-plugin` execution over `src/main/java9` with `<release>9</release>` and `<multiReleaseOutput>true</multiReleaseOutput>`. The execution stays bound to `prepare-package` so that `bnd-maven-plugin` (at `process-classes`) never sees the versioned classes, as before; the `Multi-Release: true` manifest entry keeps coming from the `bnd-multi-release` property. The published artifacts are unchanged: the versioned class list and bytecode are identical, and the stubs are no longer needed since the real classes are on the compile classpath. The Java 9 `StackLocator` tests move to `log4j-api-test` as a `maven-failsafe-plugin` integration test running against the packaged multi-release JAR, with a guard assertion that the `META-INF/versions/9` variant is actually loaded. The two `getCurrentStackTrace` tests only passed against the old module's stubbed `PrivateSecurityManagerStackTraceUtil` and are dropped: against the real classes they exercise the `SecurityManager` path, which `StackLocatorUtilTest` already covers. The Java 9 `ProcessIdUtilTest` was assertion-identical to the existing one in `log4j-api-test`. Assisted-By: Claude Fable 5 <noreply@anthropic.com>
ppkarwasz
force-pushed
the
fix/2.x/merge-java9-modules
branch
from
August 27, 2026 15:22
cd65656 to
76cb0ec
Compare
Member
Author
|
This is a test for 2026-era IDEs. Do they support multi-version Maven modules or not? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
log4j-api-java9andlog4j-core-java9modules are a relict from an era where multi-release JAR content could not be produced by the consuming Maven module itself. Each compiled a handful of Java 9 sources (padded with stub classes to satisfy the compiler, sincelog4j-api-java9had no dependency onlog4j-api), zipped the compiled classes in aclasses/META-INF/versions/9layout, and had the consumer unpack the zip intotargetatprepare-package.This PR compiles the Java 9 sources directly in
log4j-apiandlog4j-coreinstead, using a secondmaven-compiler-pluginexecution over a newsrc/main/java9source directory with<release>9</release>and<multiReleaseOutput>true</multiReleaseOutput>, and deletes the two auxiliary modules (including all their stub classes, which are no longer needed: the real classes fromtarget/classesare on the compile classpath).The published artifacts are unchanged: the versioned class list and the entry sizes in
log4j-api.jarandlog4j-core.jarare identical before and after (same compiler version, flags and JDK), theMulti-Release: truemanifest entry keeps coming from thebnd-multi-releaseproperty, and the versioned classes are still compiled at class-file version 53. The new compiler execution stays bound toprepare-packageso thatbnd-maven-plugin(running atprocess-classes) never sees the versioned classes — the same timing the zip-unpack mechanism had (cf. apache/logging-parent#93). The existingdelete-module-descriptorsclean execution keeps incremental no-clean builds correct.Other clean-ups that fall out of this:
build-helper-maven-pluginadd-sourceexecutions in both consumers (they added atarget/log4j-*-java9directory that never existed) are removed;dependencyManagemententries for the zip artifacts inlog4j-parentare removed (they were never in the published BOM, cf. LOG4J2-3241).Tests: the Java 9
StackLocatortests move tolog4j-api-testas amaven-failsafe-pluginintegration test (StackLocatorJava9IT) that runs against the packaged multi-release JAR, with a guard assertion that theMETA-INF/versions/9variant ofStackLocatoris actually loaded. Two remarks:getCurrentStackTracetests are dropped, not moved: they only passed against the old module's stubbedPrivateSecurityManagerStackTraceUtil(whoseisEnabled()returnedfalse). Against the real classes on JDK 17 they exercise theSecurityManagerpath, whichStackLocatorUtilTestalready covers. The Java 9ProcessIdUtilTestwas assertion-identical to the existing one inlog4j-api-testand is dropped too.java9package, because the pre-existing (and currently never executed)StackLocatorTestITinstalls aSecurityManagerand fails on JDK 17 without-Djava.security.manager=allow; reviving it is a separate follow-up.Visible losses:
src/main/java9now fall outside the defaultsrc/main/javaglobs of Spotless and RAT, so they lose automatic format/license-header enforcement (9 stable files; an<includes>override inlogging-parentor here is possible as a follow-up);🤖 Generated with Claude Code
https://claude.ai/code/session_01RTbXEN6DStfnmMLSMPWM9b