diff --git a/core/src/main/java/net/adoptopenjdk/icedteaweb/jvm/JvmUtils.java b/core/src/main/java/net/adoptopenjdk/icedteaweb/jvm/JvmUtils.java index ed292c65a..ec2bfc620 100644 --- a/core/src/main/java/net/adoptopenjdk/icedteaweb/jvm/JvmUtils.java +++ b/core/src/main/java/net/adoptopenjdk/icedteaweb/jvm/JvmUtils.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -374,7 +375,7 @@ public static String[] getValidStartingJavaModuleVMArguments() { * Defined in itw-modularjdk.args. Required for running ITW with jdk 9 or higher */ static Map> getPredefinedJavaModulesVMArgumentsMap() { - return new HashMap>() {{ + return new LinkedHashMap>() {{ put("--add-reads=java.base", moduleArgs("ALL-UNNAMED", "java.desktop")); put("--add-reads=java.desktop", moduleArgs("ALL-UNNAMED", "java.naming")); put("--add-reads=java.naming", moduleArgs("ALL-UNNAMED", "java.desktop")); diff --git a/core/src/main/java/net/sourceforge/jnlp/JNLPFile.java b/core/src/main/java/net/sourceforge/jnlp/JNLPFile.java index 6c2372237..78dca8195 100644 --- a/core/src/main/java/net/sourceforge/jnlp/JNLPFile.java +++ b/core/src/main/java/net/sourceforge/jnlp/JNLPFile.java @@ -43,6 +43,7 @@ import net.adoptopenjdk.icedteaweb.xmlparser.XMLParser; import net.adoptopenjdk.icedteaweb.xmlparser.XmlNode; import net.adoptopenjdk.icedteaweb.xmlparser.XmlParserFactory; +import net.sourceforge.jnlp.runtime.ApplicationInstance; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.util.UrlUtils; import sun.net.www.protocol.http.HttpURLConnection; @@ -259,7 +260,8 @@ protected JNLPFile() { parse(input, location, null); final String httpAgent = getResources().getPropertiesMap().get(HTTP_AGENT); - if (! StringUtils.isBlank(httpAgent)) { + // Do not set http.agent in stage 2 as it can be set from the vmarg to the jvm + if (! StringUtils.isBlank(httpAgent) && !"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_JNLP_RESOURCE_PROPERTIES))) { System.setProperty(HTTP_AGENT, httpAgent); if (!HttpURLConnection.userAgent.contains(httpAgent)) { LOG.warn("Cannot set HTTP User-Agent as a connection has been opened before reading the JNLP file"); diff --git a/core/src/main/java/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/core/src/main/java/net/sourceforge/jnlp/runtime/ApplicationInstance.java index d16a34f3d..17d583a7b 100644 --- a/core/src/main/java/net/sourceforge/jnlp/runtime/ApplicationInstance.java +++ b/core/src/main/java/net/sourceforge/jnlp/runtime/ApplicationInstance.java @@ -53,6 +53,7 @@ public class ApplicationInstance { private static final String DEPLOYMENT_SYSPROP = "deployment.javaws"; private static final String DEPLOYMENT_SYSPROP_VALUE = "IcedTea-Web"; + public static final String IGNORE_JNLP_RESOURCE_PROPERTIES = "ignoreJnlpResourceProperties"; // todo: should attempt to unload the environment variables // installed by the application. @@ -134,6 +135,17 @@ public void finalize() { * Install the environment variables. */ private void installEnvironment() { + setSystemPropertiesFromJnlp(); + + // The "deployment.javaws" flag is always set to "IcedTea-Web" to make it possible + // for the started application to detect the execution context. + System.setProperty(DEPLOYMENT_SYSPROP, DEPLOYMENT_SYSPROP_VALUE); + } + + private void setSystemPropertiesFromJnlp() { + if ("true".equalsIgnoreCase(System.getenv(IGNORE_JNLP_RESOURCE_PROPERTIES))) { + return; + } final List props = collectPropertiesFromJnlpHierarchy(new ArrayList<>(), file); if (!(props.size() == 0)) { @@ -146,19 +158,15 @@ private void installEnvironment() { final PrivilegedAction setPropertiesAction = () -> { for (PropertyDesc propDesc : props) { - LOG.debug("Setting Property {}", propDesc.getKey()); + LOG.debug("Setting System Property {} with value {}", propDesc.getKey(), propDesc.getValue()); System.setProperty(propDesc.getKey(), propDesc.getValue()); } return null; }; - LOG.info("about to set system properties"); + LOG.info("About to set system properties"); AccessController.doPrivileged(setPropertiesAction, acc); } - - // The "deployment.javaws" flag is always set to "IcedTea-Web" to make it possible - // for the started application to detect the execution context. - System.setProperty(DEPLOYMENT_SYSPROP, DEPLOYMENT_SYSPROP_VALUE); } /** @@ -305,5 +313,4 @@ private List collectPropertiesFromJnlpHierarchy(List } return props; } - }