From c4038d51b82b8a3199c3d4e6348d37b4f0f9b887 Mon Sep 17 00:00:00 2001 From: Muhammad Hammad Date: Mon, 21 Oct 2024 22:00:46 +0200 Subject: [PATCH] Java 21 --- src/test/java/org/dvare/dynamic/SourceTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/dvare/dynamic/SourceTest.java b/src/test/java/org/dvare/dynamic/SourceTest.java index 2751429..7ccc309 100644 --- a/src/test/java/org/dvare/dynamic/SourceTest.java +++ b/src/test/java/org/dvare/dynamic/SourceTest.java @@ -63,8 +63,10 @@ public void stringSourceImportCompileTest() throws Exception { DynamicCompiler dynamicCompiler = new DynamicCompiler(); try { - Class.forName("com.sun.tools.sjavac.Module"); //if java module present - dynamicCompiler.addCompilerOption(DynamicCompilerOption.ADD_EXPORTS, "java.base/java.time=ALL-UNNAMED"); + if (DynamicCompiler.isJava9OrAbove())//if java module present + { + dynamicCompiler.addCompilerOption(DynamicCompilerOption.ADD_EXPORTS, "java.base/java.time=ALL-UNNAMED"); + } } catch (Exception ignored) { } dynamicCompiler.addSource("org.dvare.dynamic.DateUtil", sourceCode);