This is an automated email from the ASF dual-hosted git repository. ppkarwasz pushed a commit to branch fix/2.x/merge-java9-modules in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit cd65656e1bd05ade4a6bfa2b339edc2519b96718 Author: Piotr P. Karwasz <[email protected]> AuthorDate: Thu Aug 27 17:18:11 2026 +0200 Merge `log4j-*-java9` modules into `log4j-api` and `log4j-core` 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 <[email protected]> --- log4j-api-java9/.gitignore | 1 - log4j-api-java9/pom.xml | 104 --------------------- log4j-api-java9/src/assembly/java9.xml | 36 ------- .../main/java/org/apache/logging/log4j/Dummy.java | 23 ----- .../org/apache/logging/log4j/message/Dummy.java | 23 ----- .../logging/log4j/message/ThreadDumpMessage.java | 25 ----- .../org/apache/logging/log4j/simple/Dummy.java | 23 ----- .../org/apache/logging/log4j/spi/Provider.java | 23 ----- .../org/apache/logging/log4j/status/Dummy.java | 23 ----- .../log4j/util/EnvironmentPropertySource.java | 23 ----- .../org/apache/logging/log4j/util/LoaderUtil.java | 28 ------ .../util/PrivateSecurityManagerStackTraceUtil.java | 34 ------- .../apache/logging/log4j/util/PropertySource.java | 23 ----- .../log4j/util/SystemPropertiesPropertySource.java | 23 ----- .../log4j/util/internal/SerializationUtil.java | 31 ------ .../log4j/util/java9/ProcessIdUtilTest.java | 31 ------ log4j-api-test/pom.xml | 23 +++++ .../log4j/util/java9/StackLocatorJava9IT.java | 75 ++++++--------- log4j-api/pom.xml | 48 +++------- .../org/apache/logging/log4j/util/Base64Util.java | 0 .../apache/logging/log4j/util/ProcessIdUtil.java | 0 .../apache/logging/log4j/util/StackLocator.java | 0 .../util/internal/DefaultObjectInputFilter.java | 0 log4j-core-java9/.gitignore | 1 - log4j-core-java9/pom.xml | 92 ------------------ log4j-core-java9/src/assembly/java9.xml | 37 -------- .../logging/log4j/core/impl/ExtendedClassInfo.java | 43 --------- .../core/jackson/StackTraceElementConstants.java | 31 ------ .../log4j/core/pattern/PlainTextRenderer.java | 30 ------ .../logging/log4j/core/pattern/TextRenderer.java | 30 ------ .../apache/logging/log4j/core/util/Integers.java | 27 ------ .../org/apache/logging/log4j/core/util/Dummy.java | 23 ----- log4j-core/pom.xml | 49 +++------- .../log4j/core/impl/ExtendedStackTraceElement.java | 0 .../jackson/ExtendedStackTraceElementMixIn.java | 0 .../Log4jStackTraceElementDeserializer.java | 0 .../log4j/core/jackson/StackTraceElementMixIn.java | 0 .../log4j/core/util/internal/UnsafeUtil.java | 0 log4j-parent/pom.xml | 14 --- pom.xml | 4 - src/changelog/.2.x.x/merge_java9_modules.xml | 12 +++ 41 files changed, 89 insertions(+), 924 deletions(-) diff --git a/log4j-api-java9/.gitignore b/log4j-api-java9/.gitignore deleted file mode 100644 index ae3c172604..0000000000 --- a/log4j-api-java9/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/log4j-api-java9/pom.xml b/log4j-api-java9/pom.xml deleted file mode 100644 index 5112014f8a..0000000000 --- a/log4j-api-java9/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to you under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j</artifactId> - <version>${revision}</version> - <relativePath>../log4j-parent</relativePath> - </parent> - <artifactId>log4j-api-java9</artifactId> - <packaging>pom</packaging> - <name>Apache Log4j API Java 9 support</name> - <description>The Apache Log4j API (Java 9)</description> - <properties> - <maven.deploy.skip>true</maven.deploy.skip> - <maven.compiler.release>9</maven.compiler.release> - </properties> - <dependencies> - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-engine</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <executions> - <execution> - <id>zip</id> - <goals> - <goal>single</goal> - </goals> - <phase>package</phase> - <configuration> - <finalName>log4j-api-java9-${project.version}</finalName> - <appendAssemblyId>false</appendAssemblyId> - <descriptors> - <descriptor>src/assembly/java9.xml</descriptor> - </descriptors> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <executions> - <execution> - <id>default-compile</id> - <goals> - <goal>compile</goal> - </goals> - </execution> - <execution> - <id>default-test-compile</id> - <goals> - <goal>testCompile</goal> - </goals> - <phase>test-compile</phase> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <executions> - <!-- Uses a different id than `default-test` to ignore the `java8-tests` profile --> - <execution> - <id>run-tests</id> - <goals> - <goal>test</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> diff --git a/log4j-api-java9/src/assembly/java9.xml b/log4j-api-java9/src/assembly/java9.xml deleted file mode 100644 index 0aa94e150f..0000000000 --- a/log4j-api-java9/src/assembly/java9.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to you under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<assembly> - <id>src</id> - <formats> - <format>zip</format> - </formats> - <baseDirectory>/</baseDirectory> - <fileSets> - <fileSet> - <directory>${project.build.outputDirectory}</directory> - <outputDirectory>/classes/META-INF/versions/9</outputDirectory> - <includes> - <include>org/apache/logging/log4j/util/Base64Util.class</include> - <include>org/apache/logging/log4j/util/ProcessIdUtil.class</include> - <include>org/apache/logging/log4j/util/StackLocator.class</include> - <include>org/apache/logging/log4j/util/internal/DefaultObjectInputFilter.class</include> - </includes> - </fileSet> - </fileSets> -</assembly> diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/Dummy.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/Dummy.java deleted file mode 100644 index a2b60d2fe2..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/Dummy.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public class Dummy {} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/message/Dummy.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/message/Dummy.java deleted file mode 100644 index 343013dcd4..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/message/Dummy.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.message; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public class Dummy {} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java deleted file mode 100644 index 2cef3a24ec..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.message; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public class ThreadDumpMessage { - public static interface ThreadInfoFactory {} -} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/simple/Dummy.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/simple/Dummy.java deleted file mode 100644 index 25f4cf4d22..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/simple/Dummy.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.simple; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public class Dummy {} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/spi/Provider.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/spi/Provider.java deleted file mode 100644 index 2f6fbdf314..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/spi/Provider.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.spi; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public class Provider {} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/status/Dummy.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/status/Dummy.java deleted file mode 100644 index 0004af0bfb..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/status/Dummy.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.status; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public class Dummy {} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/EnvironmentPropertySource.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/EnvironmentPropertySource.java deleted file mode 100644 index bf78f35df5..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/EnvironmentPropertySource.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.util; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public class EnvironmentPropertySource implements PropertySource {} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java deleted file mode 100644 index 6eb2c71042..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/LoaderUtil.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.util; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public final class LoaderUtil { - - public static ClassLoader getThreadContextClassLoader() { - return LoaderUtil.class.getClassLoader(); - } -} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/PrivateSecurityManagerStackTraceUtil.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/PrivateSecurityManagerStackTraceUtil.java deleted file mode 100644 index 9fb9a4ee56..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/PrivateSecurityManagerStackTraceUtil.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.util; - -import java.util.Deque; - -/** - * This is a dummy class and is only here to allow this module to compile. It will not - * be copied into the log4j-api module. - */ -final class PrivateSecurityManagerStackTraceUtil { - - static boolean isEnabled() { - return false; - } - - static Deque<Class<?>> getCurrentStackTrace() { - return null; - } -} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/PropertySource.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/PropertySource.java deleted file mode 100644 index 56e6259b5d..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/PropertySource.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.util; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public interface PropertySource {} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/SystemPropertiesPropertySource.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/SystemPropertiesPropertySource.java deleted file mode 100644 index ec8a479294..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/SystemPropertiesPropertySource.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.util; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public class SystemPropertiesPropertySource implements PropertySource {} diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/internal/SerializationUtil.java b/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/internal/SerializationUtil.java deleted file mode 100644 index ddade3dd8a..0000000000 --- a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/internal/SerializationUtil.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.util.internal; - -import java.util.List; - -/** - * Dummy class for compilation purposes only. - */ -public final class SerializationUtil { - public static final List<String> REQUIRED_JAVA_CLASSES = List.of(); - public static final List<String> REQUIRED_JAVA_PACKAGES = List.of(); - - public static String stripArray(final Class<?> clazz) { - return null; - } -} diff --git a/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/ProcessIdUtilTest.java b/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/ProcessIdUtilTest.java deleted file mode 100644 index 1a24860f57..0000000000 --- a/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/ProcessIdUtilTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.util.java9; - -import static org.junit.jupiter.api.Assertions.assertNotEquals; - -import org.apache.logging.log4j.util.ProcessIdUtil; -import org.junit.jupiter.api.Test; - -class ProcessIdUtilTest { - - @Test - void processIdTest() { - final String processId = ProcessIdUtil.getProcessId(); - assertNotEquals(processId, ProcessIdUtil.DEFAULT_PROCESSID, "ProcessId is default"); - } -} diff --git a/log4j-api-test/pom.xml b/log4j-api-test/pom.xml index aef8a1b5d6..9e5932f765 100644 --- a/log4j-api-test/pom.xml +++ b/log4j-api-test/pom.xml @@ -177,6 +177,29 @@ </configuration> </plugin> + <!-- Runs the tests for the Java 9 variants of `log4j-api` classes. + These need to run against the packaged multi-release JAR, hence the `integration-test` phase. --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <id>java9-variant-tests</id> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + <configuration> + <!-- Restricted to the `java9` package: `StackLocatorTestIT` predates this binding, + installs a `SecurityManager` and is not runnable on the build JDK as-is. --> + <includes> + <include>org/apache/logging/log4j/util/java9/*IT.java</include> + </includes> + </configuration> + </execution> + </executions> + </plugin> + </plugins> </build> </project> diff --git a/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorTest.java b/log4j-api-test/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorJava9IT.java similarity index 66% rename from log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorTest.java rename to log4j-api-test/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorJava9IT.java index cc8f61218a..42d54cefe0 100644 --- a/log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorTest.java +++ b/log4j-api-test/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorJava9IT.java @@ -16,49 +16,41 @@ */ package org.apache.logging.log4j.util.java9; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; -import java.util.Deque; -import java.util.Stack; import org.apache.logging.log4j.util.StackLocator; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -class StackLocatorTest { +/** + * Tests the Java 9 variant of {@link StackLocator} contained in the {@code META-INF/versions/9} directory of + * {@code log4j-api.jar}. + * <p> + * This test must run against the packaged multi-release JAR, hence it is an integration test. + * </p> + */ +class StackLocatorJava9IT { + + @BeforeAll + static void assertJava9VariantLoaded() { + assertThat(StackLocator.class.getResource("StackLocator.class")) + .asString() + .as("java9 variant of StackLocator must be loaded from the MRJ") + .contains("META-INF/versions/9"); + } @Test void testGetCallerClass() { - final Class<?> expected = StackLocatorTest.class; + final Class<?> expected = StackLocatorJava9IT.class; final StackLocator stackLocator = StackLocator.getInstance(); final Class<?> actual = stackLocator.getCallerClass(1); assertSame(expected, actual); } - @Test - void testGetCallerClassNameViaStackTrace() throws Exception { - final Class<?> expected = StackLocatorTest.class; - final Class<?> actual = Class.forName(new Throwable().getStackTrace()[0].getClassName()); - assertSame(expected, actual); - } - - @Test - void testGetCurrentStackTrace() { - final StackLocator stackLocator = StackLocator.getInstance(); - final Deque<Class<?>> classes = stackLocator.getCurrentStackTrace(); - final Stack<Class<?>> reversed = new Stack<>(); - reversed.ensureCapacity(classes.size()); - while (!classes.isEmpty()) { - reversed.push(classes.removeLast()); - } - while (reversed.peek() != StackLocator.class) { - reversed.pop(); - } - reversed.pop(); // ReflectionUtil - assertSame(StackLocatorTest.class, reversed.pop()); - } - @Test void testGetCallerClassViaName() { Inner.assertCallerClassViaName(); @@ -71,14 +63,14 @@ class StackLocatorTest { private static class Inner { private static void assertCallerClassViaName() { - final Class<?> expected = StackLocatorTest.class; + final Class<?> expected = StackLocatorJava9IT.class; final StackLocator stackLocator = StackLocator.getInstance(); final Class<?> actual = stackLocator.getCallerClass(Inner.class.getName(), ""); assertSame(expected, actual); } private static void assertCallerClassViaAnchorClass() { - final Class<?> expected = StackLocatorTest.class; + final Class<?> expected = StackLocatorJava9IT.class; final StackLocator stackLocator = StackLocator.getInstance(); final Class<?> actual = stackLocator.getCallerClass(Inner.class); assertSame(expected, actual); @@ -113,32 +105,25 @@ class StackLocatorTest { private StackTraceElement quux() { final StackLocator stackLocator = StackLocator.getInstance(); - return stackLocator.calcLocation("org.apache.logging.log4j.util.java9.StackLocatorTest$Bar"); + return stackLocator.calcLocation("org.apache.logging.log4j.util.java9.StackLocatorJava9IT$Bar"); } @Test void testCalcLocation() { /* * We are setting up a stack trace that looks like: - * - org.apache.logging.log4j.util.test.StackLocatorTest#quux(line:118) - * - org.apache.logging.log4j.util.test.StackLocatorTest$Bar#baz(line:112) - * - org.apache.logging.log4j.util.test.StackLocatorTest$Bar#bar(line:108) - * - org.apache.logging.log4j.util.test.StackLocatorTest$Foo(line:100) + * - org.apache.logging.log4j.util.java9.StackLocatorJava9IT#quux + * - org.apache.logging.log4j.util.java9.StackLocatorJava9IT$Bar#baz + * - org.apache.logging.log4j.util.java9.StackLocatorJava9IT$Bar#bar + * - org.apache.logging.log4j.util.java9.StackLocatorJava9IT$Foo#foo * - * We are pretending that org.apache.logging.log4j.util.test.StackLocatorTest$Bar is the logging class, and - * org.apache.logging.log4j.util.test.StackLocatorTest$Foo is where the log line emanated. + * We are pretending that org.apache.logging.log4j.util.java9.StackLocatorJava9IT$Bar is the logging class, and + * org.apache.logging.log4j.util.java9.StackLocatorJava9IT$Foo is where the log line emanated. */ final StackTraceElement element = new Foo().foo(); - assertEquals("org.apache.logging.log4j.util.java9.StackLocatorTest$Foo", element.getClassName()); + assertEquals("org.apache.logging.log4j.util.java9.StackLocatorJava9IT$Foo", element.getClassName()); // The line number below may need adjustment if this file is changed. - assertEquals(99, element.getLineNumber()); - } - - @Test - void testTopElementInStackTrace() { - final StackLocator stackLocator = StackLocator.getInstance(); - final Deque<Class<?>> classes = stackLocator.getCurrentStackTrace(); - assertSame(StackLocator.class, classes.getFirst()); + assertEquals(91, element.getLineNumber()); } @Test diff --git a/log4j-api/pom.xml b/log4j-api/pom.xml index 4b0525466d..00f985142b 100644 --- a/log4j-api/pom.xml +++ b/log4j-api/pom.xml @@ -77,50 +77,26 @@ <build> <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>add-source</id> - <goals> - <goal>add-source</goal> - </goals> - <phase>generate-sources</phase> - <configuration> - <sources> - <source>${project.build.directory}/log4j-api-java9</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> + <artifactId>maven-compiler-plugin</artifactId> <executions> + <!-- Compiles the Java 9 variants of some classes to `META-INF/versions/9`. + Bound to `prepare-package` so that `bnd-maven-plugin` (running at `process-classes`) + does not see the versioned classes. + The `Multi-Release: true` manifest entry is provided by the `bnd-multi-release` property above. --> <execution> - <id>unpack-classes</id> + <id>compile-java9</id> <goals> - <goal>unpack</goal> + <goal>compile</goal> </goals> <phase>prepare-package</phase> <configuration> - <artifactItems> - <artifactItem> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api-java9</artifactId> - <version>${project.version}</version> - <type>zip</type> - <overWrite>false</overWrite> - </artifactItem> - </artifactItems> - <includes>**/*.class</includes> - <excludes>**/*.java</excludes> - <outputDirectory>${project.build.directory}</outputDirectory> - <overWriteReleases>false</overWriteReleases> - <overWriteSnapshots>true</overWriteSnapshots> + <release>9</release> + <compileSourceRoots> + <compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot> + </compileSourceRoots> + <multiReleaseOutput>true</multiReleaseOutput> </configuration> </execution> </executions> diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/Base64Util.java b/log4j-api/src/main/java9/org/apache/logging/log4j/util/Base64Util.java similarity index 100% rename from log4j-api-java9/src/main/java/org/apache/logging/log4j/util/Base64Util.java rename to log4j-api/src/main/java9/org/apache/logging/log4j/util/Base64Util.java diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/ProcessIdUtil.java b/log4j-api/src/main/java9/org/apache/logging/log4j/util/ProcessIdUtil.java similarity index 100% rename from log4j-api-java9/src/main/java/org/apache/logging/log4j/util/ProcessIdUtil.java rename to log4j-api/src/main/java9/org/apache/logging/log4j/util/ProcessIdUtil.java diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/StackLocator.java b/log4j-api/src/main/java9/org/apache/logging/log4j/util/StackLocator.java similarity index 100% rename from log4j-api-java9/src/main/java/org/apache/logging/log4j/util/StackLocator.java rename to log4j-api/src/main/java9/org/apache/logging/log4j/util/StackLocator.java diff --git a/log4j-api-java9/src/main/java/org/apache/logging/log4j/util/internal/DefaultObjectInputFilter.java b/log4j-api/src/main/java9/org/apache/logging/log4j/util/internal/DefaultObjectInputFilter.java similarity index 100% rename from log4j-api-java9/src/main/java/org/apache/logging/log4j/util/internal/DefaultObjectInputFilter.java rename to log4j-api/src/main/java9/org/apache/logging/log4j/util/internal/DefaultObjectInputFilter.java diff --git a/log4j-core-java9/.gitignore b/log4j-core-java9/.gitignore deleted file mode 100644 index ae3c172604..0000000000 --- a/log4j-core-java9/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/log4j-core-java9/pom.xml b/log4j-core-java9/pom.xml deleted file mode 100644 index 2cb3c3d07a..0000000000 --- a/log4j-core-java9/pom.xml +++ /dev/null @@ -1,92 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to you under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j</artifactId> - <version>${revision}</version> - <relativePath>../log4j-parent</relativePath> - </parent> - <artifactId>log4j-core-java9</artifactId> - <packaging>pom</packaging> - <name>Apache Log4j Implementation Java 9 support</name> - <description>The Apache Log4j Implementation (Java 9)</description> - <properties> - <maven.compiler.release>9</maven.compiler.release> - <maven.deploy.skip>true</maven.deploy.skip> - <sign.skip>true</sign.skip> - </properties> - <dependencies> - <!-- Naturally, all implementations require the log4j-api JAR --> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.dataformat</groupId> - <artifactId>jackson-dataformat-xml</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-core</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <executions> - <execution> - <id>zip</id> - <goals> - <goal>single</goal> - </goals> - <phase>package</phase> - <configuration> - <finalName>log4j-core-java9-${project.version}</finalName> - <appendAssemblyId>false</appendAssemblyId> - <descriptors> - <descriptor>src/assembly/java9.xml</descriptor> - </descriptors> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <executions> - <execution> - <id>default-compile</id> - <goals> - <goal>compile</goal> - </goals> - <phase>compile</phase> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> diff --git a/log4j-core-java9/src/assembly/java9.xml b/log4j-core-java9/src/assembly/java9.xml deleted file mode 100644 index 4349d38f14..0000000000 --- a/log4j-core-java9/src/assembly/java9.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to you under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<assembly> - <id>src</id> - <formats> - <format>zip</format> - </formats> - <baseDirectory>/</baseDirectory> - <fileSets> - <fileSet> - <directory>${project.build.outputDirectory}</directory> - <outputDirectory>/classes/META-INF/versions/9</outputDirectory> - <includes> - <include>org/apache/logging/log4j/core/impl/ExtendedStackTraceElement.class</include> - <include>org/apache/logging/log4j/core/jackson/ExtendedStackTraceElementMixIn.class</include> - <include>org/apache/logging/log4j/core/jackson/Log4jStackTraceElementDeserializer.class</include> - <include>org/apache/logging/log4j/core/jackson/StackTraceElementMixIn.class</include> - <include>org/apache/logging/log4j/core/util/internal/UnsafeUtil*.class</include> - </includes> - </fileSet> - </fileSets> -</assembly> diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/impl/ExtendedClassInfo.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/impl/ExtendedClassInfo.java deleted file mode 100644 index 61faeb9e81..0000000000 --- a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/impl/ExtendedClassInfo.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.core.impl; - -import java.io.Serializable; -import org.apache.logging.log4j.core.pattern.TextRenderer; - -/** - * Dummy class to let ExtendedStackTracElement to compile. It will not be copied - * to `log4j-core`. - */ -public class ExtendedClassInfo implements Serializable { - - public ExtendedClassInfo(final boolean exact, final String location, final String version) {} - - public boolean getExact() { - return false; - } - - public String getLocation() { - return null; - } - - public String getVersion() { - return null; - } - - public void renderOn(final StringBuilder output, final TextRenderer textRenderer) {} -} diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/jackson/StackTraceElementConstants.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/jackson/StackTraceElementConstants.java deleted file mode 100644 index b54a9bc33e..0000000000 --- a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/jackson/StackTraceElementConstants.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.core.jackson; - -/** - * Defines constants use for naming stack trace elements. - */ -public class StackTraceElementConstants { - - public static final String ATTR_CLASS_LOADER_NAME = "classLoaderName"; - public static final String ATTR_MODULE = "module"; - public static final String ATTR_MODULE_VERSION = "moduleVersion"; - public static final String ATTR_CLASS = "class"; - public static final String ATTR_FILE = "file"; - public static final String ATTR_LINE = "line"; - public static final String ATTR_METHOD = "method"; -} diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/pattern/PlainTextRenderer.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/pattern/PlainTextRenderer.java deleted file mode 100644 index a1c187bba3..0000000000 --- a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/pattern/PlainTextRenderer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.core.pattern; - -import org.apache.logging.log4j.core.impl.ExtendedStackTraceElement; - -/** - * Dummy class to allow {@link ExtendedStackTraceElement} to compile. It will - * not be copied to `log4j-core`. - */ -public abstract class PlainTextRenderer implements TextRenderer { - - public static PlainTextRenderer getInstance() { - return null; - } -} diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/pattern/TextRenderer.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/pattern/TextRenderer.java deleted file mode 100644 index d7983969e6..0000000000 --- a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/pattern/TextRenderer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.core.pattern; - -import org.apache.logging.log4j.core.impl.ExtendedStackTraceElement; - -/** - * Dummy class to allow {@link ExtendedStackTraceElement} to compile. It will - * not be copied to `log4j-core`. - */ -public interface TextRenderer { - - void render(String input, StringBuilder output, String styleName); - - void render(StringBuilder input, StringBuilder output); -} diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/Integers.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/Integers.java deleted file mode 100644 index 8dbb6320a9..0000000000 --- a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/Integers.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.core.util; - -/** - * Dummy class used for compilation. It will not be copied to `log4j-core`. - */ -public class Integers { - - public static int parseInt(String value) { - return 0; - } -} diff --git a/log4j-core-java9/src/test/java/org/apache/logging/log4j/core/util/Dummy.java b/log4j-core-java9/src/test/java/org/apache/logging/log4j/core/util/Dummy.java deleted file mode 100644 index 047439d5d3..0000000000 --- a/log4j-core-java9/src/test/java/org/apache/logging/log4j/core/util/Dummy.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.logging.log4j.core.util; - -/** - * This is a dummy class and is only here to allow module-info.java to compile. It will not - * be copied into the log4j-api module. - */ -public class Dummy {} diff --git a/log4j-core/pom.xml b/log4j-core/pom.xml index b2f34d4ab9..e0c8205f67 100644 --- a/log4j-core/pom.xml +++ b/log4j-core/pom.xml @@ -227,51 +227,26 @@ <build> <plugins> - <!-- Add Java 9+ code for the MRJ --> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>add-source</id> - <goals> - <goal>add-source</goal> - </goals> - <phase>generate-sources</phase> - <configuration> - <sources> - <source>${project.build.directory}/log4j-core-java9</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> + <artifactId>maven-compiler-plugin</artifactId> <executions> + <!-- Compiles the Java 9 variants of some classes to `META-INF/versions/9`. + Bound to `prepare-package` so that `bnd-maven-plugin` (running at `process-classes`) + does not see the versioned classes. + The `Multi-Release: true` manifest entry is provided by the `bnd-multi-release` property above. --> <execution> - <id>unpack-classes</id> + <id>compile-java9</id> <goals> - <goal>unpack</goal> + <goal>compile</goal> </goals> <phase>prepare-package</phase> <configuration> - <artifactItems> - <artifactItem> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core-java9</artifactId> - <version>${project.version}</version> - <type>zip</type> - <overWrite>false</overWrite> - </artifactItem> - </artifactItems> - <includes>**/*.class</includes> - <excludes>**/*.java</excludes> - <outputDirectory>${project.build.directory}</outputDirectory> - <overWriteReleases>false</overWriteReleases> - <overWriteSnapshots>true</overWriteSnapshots> + <release>9</release> + <compileSourceRoots> + <compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot> + </compileSourceRoots> + <multiReleaseOutput>true</multiReleaseOutput> </configuration> </execution> </executions> diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/impl/ExtendedStackTraceElement.java b/log4j-core/src/main/java9/org/apache/logging/log4j/core/impl/ExtendedStackTraceElement.java similarity index 100% rename from log4j-core-java9/src/main/java/org/apache/logging/log4j/core/impl/ExtendedStackTraceElement.java rename to log4j-core/src/main/java9/org/apache/logging/log4j/core/impl/ExtendedStackTraceElement.java diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/jackson/ExtendedStackTraceElementMixIn.java b/log4j-core/src/main/java9/org/apache/logging/log4j/core/jackson/ExtendedStackTraceElementMixIn.java similarity index 100% rename from log4j-core-java9/src/main/java/org/apache/logging/log4j/core/jackson/ExtendedStackTraceElementMixIn.java rename to log4j-core/src/main/java9/org/apache/logging/log4j/core/jackson/ExtendedStackTraceElementMixIn.java diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/jackson/Log4jStackTraceElementDeserializer.java b/log4j-core/src/main/java9/org/apache/logging/log4j/core/jackson/Log4jStackTraceElementDeserializer.java similarity index 100% rename from log4j-core-java9/src/main/java/org/apache/logging/log4j/core/jackson/Log4jStackTraceElementDeserializer.java rename to log4j-core/src/main/java9/org/apache/logging/log4j/core/jackson/Log4jStackTraceElementDeserializer.java diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/jackson/StackTraceElementMixIn.java b/log4j-core/src/main/java9/org/apache/logging/log4j/core/jackson/StackTraceElementMixIn.java similarity index 100% rename from log4j-core-java9/src/main/java/org/apache/logging/log4j/core/jackson/StackTraceElementMixIn.java rename to log4j-core/src/main/java9/org/apache/logging/log4j/core/jackson/StackTraceElementMixIn.java diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/internal/UnsafeUtil.java b/log4j-core/src/main/java9/org/apache/logging/log4j/core/util/internal/UnsafeUtil.java similarity index 100% rename from log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/internal/UnsafeUtil.java rename to log4j-core/src/main/java9/org/apache/logging/log4j/core/util/internal/UnsafeUtil.java diff --git a/log4j-parent/pom.xml b/log4j-parent/pom.xml index 28c371abef..846d01dcd1 100644 --- a/log4j-parent/pom.xml +++ b/log4j-parent/pom.xml @@ -234,20 +234,6 @@ <scope>import</scope> </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api-java9</artifactId> - <version>${project.version}</version> - <type>zip</type> - </dependency> - - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core-java9</artifactId> - <version>${project.version}</version> - <type>zip</type> - </dependency> - <!-- Dummy dependency to trick `dependabot` into updating the `log4j-transform.version` property: --> <dependency> <groupId>org.apache.logging.log4j</groupId> diff --git a/pom.xml b/pom.xml index be528c33bb..49702846ff 100644 --- a/pom.xml +++ b/pom.xml @@ -240,10 +240,6 @@ <!-- the parent POM must come first: --> <module>log4j-parent</module> - <!-- Next unpublished, but internally and *implicitly* (e.g., as a plugin dependency) consumed modules in alphabetical order: --> - <module>log4j-api-java9</module> - <module>log4j-core-java9</module> - <!-- Last comes the rest of the modules in alphabetical order. Note that modules here must have a corresponding entry in `dependencyManagement > dependencies` block below! --> <module>log4j-1.2-api</module> diff --git a/src/changelog/.2.x.x/merge_java9_modules.xml b/src/changelog/.2.x.x/merge_java9_modules.xml new file mode 100644 index 0000000000..228665ce14 --- /dev/null +++ b/src/changelog/.2.x.x/merge_java9_modules.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entry xmlns="https://logging.apache.org/xml/ns" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + https://logging.apache.org/xml/ns + https://logging.apache.org/xml/ns/log4j-changelog-0.xsd" + type="changed"> + <description format="asciidoc"> + Merge the auxiliary `log4j-api-java9` and `log4j-core-java9` modules into `log4j-api` and `log4j-core` by compiling the Java-9-specific sources directly into `META-INF/versions/9` of each JAR. + The published artifacts are unchanged. + </description> +</entry>
