From d58c95b0e1623895191bb5fe4c4fe09cfe94bb28 Mon Sep 17 00:00:00 2001 From: Kenneth VanderLinde Date: Thu, 18 Jun 2026 15:21:55 -0700 Subject: [PATCH 1/2] Programmatically set sun.java2d.d3d, polyglot.engine.WarnInterpreterOnly, and java.util.Arrays.useLegacyMergeSort --- build.gradle | 4 +--- .../net/rptools/maptool/client/LaunchInstructions.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 4711001b69..1cb099c77c 100644 --- a/build.gradle +++ b/build.gradle @@ -93,9 +93,7 @@ ext { } def javaArgs = [ - "-Xss8M", "-Dsun.java2d.d3d=false", - "-Dpolyglot.engine.WarnInterpreterOnly=false", - "-Djava.util.Arrays.useLegacyMergeSort=true", + "-Xss8M", "--add-opens=java.desktop/java.awt=ALL-UNNAMED", "--add-opens=java.desktop/java.awt.geom=ALL-UNNAMED", "--add-opens=java.desktop/sun.awt.geom=ALL-UNNAMED", "--add-opens=java.base/java.util=ALL-UNNAMED", "--add-opens=javafx.web/javafx.scene.web=ALL-UNNAMED", "--add-opens=javafx.web/com.sun.webkit=ALL-UNNAMED", diff --git a/src/main/java/net/rptools/maptool/client/LaunchInstructions.java b/src/main/java/net/rptools/maptool/client/LaunchInstructions.java index 074ad1138f..f0845e284c 100644 --- a/src/main/java/net/rptools/maptool/client/LaunchInstructions.java +++ b/src/main/java/net/rptools/maptool/client/LaunchInstructions.java @@ -27,6 +27,16 @@ public class LaunchInstructions { + "MapTool will launch anyway, but it is recommended that you increase the maximum memory allocated or don't set a limit."; static { + if (System.getProperty("sun.java2d.d3d") == null) { + System.setProperty("sun.java2d.d3d", "false"); + } + if (System.getProperty("polyglot.engine.WarnInterpreterOnly") == null) { + System.setProperty("polyglot.engine.WarnInterpreterOnly", "false"); + } + if (System.getProperty("java.util.Arrays.useLegacyMergeSort") == null) { + System.setProperty("java.util.Arrays.useLegacyMergeSort", "true"); + } + // This will inject additional data tags in log4j2 which will be picked up by Sentry.io System.setProperty("log4j2.isThreadContextMapInheritable", "true"); // This sets up log4j to capture logging from Java logging manager From a513a65ba849fe4c2c3fb1b2f6f5db9eeea3d8b2 Mon Sep 17 00:00:00 2001 From: Kenneth VanderLinde Date: Thu, 18 Jun 2026 15:19:38 -0700 Subject: [PATCH 2/2] Generic way to define default system property values in LaunchInstructions --- .../maptool/client/LaunchInstructions.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/LaunchInstructions.java b/src/main/java/net/rptools/maptool/client/LaunchInstructions.java index f0845e284c..3a55b65ea7 100644 --- a/src/main/java/net/rptools/maptool/client/LaunchInstructions.java +++ b/src/main/java/net/rptools/maptool/client/LaunchInstructions.java @@ -14,6 +14,7 @@ */ package net.rptools.maptool.client; +import java.util.Properties; import javax.swing.JFrame; import javax.swing.JOptionPane; import org.apache.logging.log4j.LogManager; @@ -27,25 +28,26 @@ public class LaunchInstructions { + "MapTool will launch anyway, but it is recommended that you increase the maximum memory allocated or don't set a limit."; static { - if (System.getProperty("sun.java2d.d3d") == null) { - System.setProperty("sun.java2d.d3d", "false"); - } - if (System.getProperty("polyglot.engine.WarnInterpreterOnly") == null) { - System.setProperty("polyglot.engine.WarnInterpreterOnly", "false"); - } - if (System.getProperty("java.util.Arrays.useLegacyMergeSort") == null) { - System.setProperty("java.util.Arrays.useLegacyMergeSort", "true"); + var defaultProperties = new Properties(); + defaultProperties.put("sun.java2d.d3d", "false"); + defaultProperties.put("sun.java2d.opengl", "false"); + defaultProperties.put("polyglot.engine.WarnInterpreterOnly", "false"); + defaultProperties.put("java.util.Arrays.useLegacyMergeSort", "true"); + // This sets up log4j to capture logging from Java logging manager + defaultProperties.put("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager"); + defaultProperties.put(AppUtil.DATADIR_PROPERTY_NAME, ".maptool-rptools"); + + for (var entry : defaultProperties.entrySet()) { + var key = entry.getKey().toString(); + + // Allow the user to provide an alternative value. + if (System.getProperty(key) == null) { + System.setProperty(key, entry.getValue().toString()); + } } // This will inject additional data tags in log4j2 which will be picked up by Sentry.io System.setProperty("log4j2.isThreadContextMapInheritable", "true"); - // This sets up log4j to capture logging from Java logging manager - if (System.getProperty("java.util.logging.manager") == null) { - System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager"); - } - if (System.getProperty(AppUtil.DATADIR_PROPERTY_NAME) == null) { - System.setProperty(AppUtil.DATADIR_PROPERTY_NAME, ".maptool-rptools"); - } ThreadContext.put("OS", System.getProperty("os.name")); }