From 77fa8b6186ba8c7e14a5332cfd00cf99d44ab96f Mon Sep 17 00:00:00 2001 From: Robinson Date: Thu, 20 Jan 2022 01:09:02 +0100 Subject: [PATCH] Added java11 args --- .../ProcessExecutorShutdownHookTest.kt | 1 + .../shutdown/WriterLoopStarterAfterExit.java | 35 +++++++++++++++++-- .../shutdown/WriterLoopStarterBeforeExit.java | 1 + 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/test/dorkbox/executor/shutdown/ProcessExecutorShutdownHookTest.kt b/test/dorkbox/executor/shutdown/ProcessExecutorShutdownHookTest.kt index 56ad18b..e4a2592 100644 --- a/test/dorkbox/executor/shutdown/ProcessExecutorShutdownHookTest.kt +++ b/test/dorkbox/executor/shutdown/ProcessExecutorShutdownHookTest.kt @@ -54,6 +54,7 @@ class ProcessExecutorShutdownHookTest { .enableRead() .defaultLogger() .asJvmProcess() + .addArg("-add-opens java.base/java.lang=ALL-UNNAMED") .cloneClasspath() .setMainClass(TestSetup.getFile(loopStarterClassFile)) .startBlocking() diff --git a/test/dorkbox/executor/shutdown/WriterLoopStarterAfterExit.java b/test/dorkbox/executor/shutdown/WriterLoopStarterAfterExit.java index bb911cb..cf5dac2 100644 --- a/test/dorkbox/executor/shutdown/WriterLoopStarterAfterExit.java +++ b/test/dorkbox/executor/shutdown/WriterLoopStarterAfterExit.java @@ -19,6 +19,9 @@ package dorkbox.executor.shutdown; +import java.io.File; +import java.io.IOException; + import dorkbox.executor.Executor; import dorkbox.executor.samples.TestSetup; @@ -44,13 +47,39 @@ class WriterLoopStarterAfterExit implements Runnable { public void run() { try { - new Executor("java", TestSetup.INSTANCE.getFile(WriterLoop.class)) - .destroyOnExit() - .startBlocking(); + // silly workarounds, because executing java files from CLI, require SINGLE-FILE access! + String path = getFile(WriterLoopStarterBeforeExit.class) + .replace(WriterLoopStarterBeforeExit.class.getSimpleName(), "WriterLoop"); + + System.out.println("Starting output: " + path); + + new Executor() + .redirectOutputAsInfo() + .redirectErrorAsInfo() + .asJvmProcess() + .addArg("-add-opens java.base/java.lang=ALL-UNNAMED") + .cloneClasspath() + .setMainClass(path) + .startBlocking(); + Thread.sleep(SLEEP_AFTER_START); } catch (Exception e) { e.printStackTrace(); } } + + + private static String getFile(Class javaClass) throws IOException { + String properName; + + if (Executor.Companion.getIS_OS_WINDOWS()) { + properName = javaClass.getName().replace('.', '\\'); + } else { + properName = javaClass.getName().replace('.', '/'); + } + + File file = new File("test", properName + ".java").getAbsoluteFile().getCanonicalFile(); + return file.getPath(); + } } diff --git a/test/dorkbox/executor/shutdown/WriterLoopStarterBeforeExit.java b/test/dorkbox/executor/shutdown/WriterLoopStarterBeforeExit.java index 868261e..ec9e0fe 100644 --- a/test/dorkbox/executor/shutdown/WriterLoopStarterBeforeExit.java +++ b/test/dorkbox/executor/shutdown/WriterLoopStarterBeforeExit.java @@ -44,6 +44,7 @@ class WriterLoopStarterBeforeExit { .redirectOutputAsInfo() .redirectErrorAsInfo() .asJvmProcess() + .addArg("-add-opens java.base/java.lang=ALL-UNNAMED") .cloneClasspath() .setMainClass(path) .startBlocking();