From 13ff5ef60da8f1b4521558dea4ec3a0dce048cdd Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Mon, 22 Jan 2024 17:34:12 -0800 Subject: [PATCH 1/2] Upgrade to latest GraalJS version --- api/src/org/labkey/api/util/ContextListener.java | 9 +++++++++ core/build.gradle | 15 +-------------- .../org/labkey/core/wiki/MarkdownServiceImpl.java | 10 ---------- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/api/src/org/labkey/api/util/ContextListener.java b/api/src/org/labkey/api/util/ContextListener.java index 2f82bfa7de2..79fb9005fed 100644 --- a/api/src/org/labkey/api/util/ContextListener.java +++ b/api/src/org/labkey/api/util/ContextListener.java @@ -39,6 +39,8 @@ */ public class ContextListener implements ServletContextListener { + public static final String POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY = "polyglot.engine.WarnInterpreterOnly"; + // this is among the earliest classes loaded (except for classes loaded via annotations @ClientEndpoint @ServerEndpoint etc) // IMPORTANT see also LabKeyBootstrapClassLoader/PipelineBootstrapConfig which duplicates this code, keep them consistent @@ -59,6 +61,13 @@ public class ContextListener implements ServletContextListener } // As of log4j2 2.17.2, we must declare languages referenced in log4j2.xml. Our DefaultRolloverStrategy uses rhino. System.setProperty("log4j2.Script.enableLanguages", "rhino"); + + // Issue 47679 - suppress stdout logging from GraalJS about compilation mode, due to significant difficulties + // in getting the VM configured to use compilation mode + if (System.getProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY) == null) + { + System.setProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY, "false"); + } } // NOTE: this line of code with LogManager.getLogger() has to happen after System.setProperty(LOG_HOME_PROPERTY_NAME) diff --git a/core/build.gradle b/core/build.gradle index ed2bbf7802a..ea43a91ed67 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -47,20 +47,7 @@ dependencies { BuildUtils.addExternalDependency( project, new ExternalDependency( - "org.graalvm.sdk:graal-sdk:${graalVersion}", - "GraalJS", - "GraalJS", - "https://github.com/graalvm/graaljs", - "Universal Permissive License", - "https://github.com/graalvm/graaljs/blob/master/LICENSE", - "Server-side JavaScript evaluation" - ) - ) - - BuildUtils.addExternalDependency( - project, - new ExternalDependency( - "org.graalvm.js:js:${graalVersion}", + "org.graalvm.polyglot:js-community:${graalVersion}", "GraalJS", "GraalJS", "https://github.com/graalvm/graaljs", diff --git a/core/src/org/labkey/core/wiki/MarkdownServiceImpl.java b/core/src/org/labkey/core/wiki/MarkdownServiceImpl.java index 18f3711bc80..9aee041a67b 100644 --- a/core/src/org/labkey/core/wiki/MarkdownServiceImpl.java +++ b/core/src/org/labkey/core/wiki/MarkdownServiceImpl.java @@ -50,9 +50,6 @@ public class MarkdownServiceImpl implements MarkdownService private static class PoolFactory implements KeyedPoolableObjectFactory, MarkdownInvocable> { - - public static final String POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY = "polyglot.engine.WarnInterpreterOnly"; - @Override public MarkdownInvocable makeObject(Map options) throws Exception { @@ -61,13 +58,6 @@ public MarkdownInvocable makeObject(Map options) throws Except if (null == svc) throw new ConfigurationException("LabKeyScriptEngineManager service not found."); - // Issue 47679 - suppress stdout logging from Graal about compilation mode, due to significant difficulties - // in getting the VM configured to use compilation mode - if (System.getProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY) == null) - { - System.setProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY, "false"); - } - ScriptEngine engine = svc.getEngineByName("graal.js"); if (null == engine) throw new ConfigurationException("Graal.js engine not found"); From e6a6d0b485f793bcfa55f8d5c397f121433fe50e Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Mon, 22 Jan 2024 18:06:29 -0800 Subject: [PATCH 2/2] Move system property setting back to MarkdownServiceImpl. GraalJS actually broke the property handling, so setting it earlier isn't going to help. We'll just wait until they ship 24.x. --- api/src/org/labkey/api/util/ContextListener.java | 9 --------- .../org/labkey/core/wiki/MarkdownServiceImpl.java | 12 ++++++++++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/api/src/org/labkey/api/util/ContextListener.java b/api/src/org/labkey/api/util/ContextListener.java index 79fb9005fed..2f82bfa7de2 100644 --- a/api/src/org/labkey/api/util/ContextListener.java +++ b/api/src/org/labkey/api/util/ContextListener.java @@ -39,8 +39,6 @@ */ public class ContextListener implements ServletContextListener { - public static final String POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY = "polyglot.engine.WarnInterpreterOnly"; - // this is among the earliest classes loaded (except for classes loaded via annotations @ClientEndpoint @ServerEndpoint etc) // IMPORTANT see also LabKeyBootstrapClassLoader/PipelineBootstrapConfig which duplicates this code, keep them consistent @@ -61,13 +59,6 @@ public class ContextListener implements ServletContextListener } // As of log4j2 2.17.2, we must declare languages referenced in log4j2.xml. Our DefaultRolloverStrategy uses rhino. System.setProperty("log4j2.Script.enableLanguages", "rhino"); - - // Issue 47679 - suppress stdout logging from GraalJS about compilation mode, due to significant difficulties - // in getting the VM configured to use compilation mode - if (System.getProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY) == null) - { - System.setProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY, "false"); - } } // NOTE: this line of code with LogManager.getLogger() has to happen after System.setProperty(LOG_HOME_PROPERTY_NAME) diff --git a/core/src/org/labkey/core/wiki/MarkdownServiceImpl.java b/core/src/org/labkey/core/wiki/MarkdownServiceImpl.java index 9aee041a67b..2197c25a495 100644 --- a/core/src/org/labkey/core/wiki/MarkdownServiceImpl.java +++ b/core/src/org/labkey/core/wiki/MarkdownServiceImpl.java @@ -50,6 +50,18 @@ public class MarkdownServiceImpl implements MarkdownService private static class PoolFactory implements KeyedPoolableObjectFactory, MarkdownInvocable> { + public static final String POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY = "polyglot.engine.WarnInterpreterOnly"; + + static + { + // Issue 47679 - suppress stdout logging from GraalJS about compilation mode, due to significant difficulties + // in getting the VM configured to use compilation mode + if (System.getProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY) == null) + { + System.setProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY, "false"); + } + } + @Override public MarkdownInvocable makeObject(Map options) throws Exception {