Remove `jvmrunargs` lookup (#3874)
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsJmxLookupTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsJmxLookupTest.java
deleted file mode 100644
index fd60f1c..0000000
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsJmxLookupTest.java
+++ /dev/null
@@ -1,52 +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.lookup;
-
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import java.util.Map;
-
-/**
- * Tests {@link JmxRuntimeInputArgumentsLookup} from the command line, not a JUnit test.
- *
- * From an IDE or CLI: --file foo.txt
- *
- * @since 2.1
- */
-public class MainInputArgumentsJmxLookupTest {
-
- public static void main(final String[] args) {
- new MainInputArgumentsJmxLookupTest().callFromMain();
- }
-
- public void callFromMain() {
- final JmxRuntimeInputArgumentsLookup lookup = JmxRuntimeInputArgumentsLookup.JMX_SINGLETON;
- String result1 = null;
- assertNull(result1);
- String result = null;
- final Map<String, String> map = lookup.getMap();
- result = map == null ? null : map.get("X");
- assertNull(result);
- // Eclipse adds -Dfile.encoding=Cp1252
- // assertEquals("--file", lookup.lookup("0"));
- // assertEquals("foo.txt", lookup.lookup("1"));
- //
- // JMX does not include the main arguments.
- // assertEquals("foo.txt", lookup.lookup("--file"));
- // assertEquals(null, lookup.lookup("foo.txt"));
- }
-}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
index 41f270a..ce6354a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
@@ -53,8 +53,6 @@
private static final String LOOKUP_KEY_JNDI = "jndi";
- private static final String LOOKUP_KEY_JVMRUNARGS = "jvmrunargs";
-
private static final Logger LOGGER = StatusLogger.getLogger();
private final Map<String, StrLookup> strLookupMap = new HashMap<>();
@@ -126,11 +124,6 @@
+ " JNDI string lookups will not be available, continuing configuration. Ignoring "
+ t);
break;
- case LOOKUP_KEY_JVMRUNARGS:
- // java.lang.VerifyError: org/apache/logging/log4j/core/lookup/JmxRuntimeInputArgumentsLookup
- LOGGER.warn("JMX runtime input lookup class is not available because this JRE does not support JMX. "
- + "JMX lookups will not be available, continuing configuration. Ignoring " + t);
- break;
case LOOKUP_KEY_WEB:
LOGGER.info("Log4j appears to be running in a Servlet environment, but there's no log4j-web module "
+ "available. If you want better web container support, please add the log4j-web JAR to your "
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/JmxRuntimeInputArgumentsLookup.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/JmxRuntimeInputArgumentsLookup.java
deleted file mode 100644
index 6fcf543..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/JmxRuntimeInputArgumentsLookup.java
+++ /dev/null
@@ -1,71 +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.lookup;
-
-import java.lang.management.ManagementFactory;
-import java.util.Collections;
-import java.util.Map;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.util.internal.SystemUtils;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Maps JVM input arguments (but not main arguments) using JMX to acquire JVM arguments.
- *
- * @see java.lang.management.RuntimeMXBean#getInputArguments()
- * @since 2.1
- */
-@Plugin(name = "jvmrunargs", category = StrLookup.CATEGORY)
-public class JmxRuntimeInputArgumentsLookup extends MapLookup {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- public static final JmxRuntimeInputArgumentsLookup JMX_SINGLETON = new JmxRuntimeInputArgumentsLookup();
-
- /**
- * Constructor when used directly as a plugin.
- */
- public JmxRuntimeInputArgumentsLookup() {
- this(getMapFromJmx());
- }
-
- public JmxRuntimeInputArgumentsLookup(final Map<String, String> map) {
- super(map);
- }
-
- @Override
- public String lookup(final LogEvent ignored, final String key) {
- if (key == null) {
- return null;
- }
- final Map<String, String> map = getMap();
- return map == null ? null : map.get(key);
- }
-
- private static Map<String, String> getMapFromJmx() {
- if (!SystemUtils.isOsAndroid()) {
- try {
- return MapLookup.toMap(ManagementFactory.getRuntimeMXBean().getInputArguments());
- } catch (LinkageError e) {
- LOGGER.warn("Failed to get JMX arguments from JVM.", e);
- }
- }
- return Collections.emptyMap();
- }
-}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/package-info.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/package-info.java
index 97fc2f0..47fab50 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/package-info.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/package-info.java
@@ -20,9 +20,11 @@
* {@linkplain org.apache.logging.log4j.core.config.plugins.Plugin#category() plugin category}
* {@link org.apache.logging.log4j.core.lookup.StrLookup#CATEGORY Lookup}.
*/
+@BaselineIgnore("2.26.0")
@Export
-@Version("2.24.1")
+@Version("2.26.0")
package org.apache.logging.log4j.core.lookup;
+import aQute.bnd.annotation.baseline.BaselineIgnore;
import org.osgi.annotation.bundle.Export;
import org.osgi.annotation.versioning.Version;
diff --git a/src/changelog/.2.x.x/3874_remove_jvmrunargs_lookup.xml b/src/changelog/.2.x.x/3874_remove_jvmrunargs_lookup.xml
new file mode 100644
index 0000000..ef0c285
--- /dev/null
+++ b/src/changelog/.2.x.x/3874_remove_jvmrunargs_lookup.xml
@@ -0,0 +1,13 @@
+<?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="removed">
+ <issue id="3874" link="https://github.com/apache/logging-log4j2/pull/3874"/>
+
+ <description format="asciidoc">
+ Remove the `jvmrunargs` lookup.
+ </description>
+</entry>