-
Bug
-
Resolution: Done
-
Major
-
None
-
None
The launcher API checks the $JAVA_HOME/jmods directory and if missing assumes it's a non-modular JVM, e.g. Java 8 or lower. In some cases this directory does not exist. We need a better way to determine the JVM version.
It's done in the wildfly-maven-plugin like:
/** * Checks to see if the {@code javaHome} is a modular JVM. * * @param javaHome the Java Home if {@code null} an attempt to discover the Java Home will be done * * @return {@code true} if this is a modular environment */ public static boolean isModularJvm(final Path javaHome) { boolean result; final List<String> cmd = new ArrayList<>(); cmd.add(getJavaCommand(javaHome)); cmd.add("--add-modules=java.se"); cmd.add("-version"); final ProcessBuilder builder = new ProcessBuilder(cmd); Process process = null; Path stdout = null; try { // Create a temporary file for stdout stdout = Files.createTempFile("stdout", ".txt"); process = builder.redirectErrorStream(true) .redirectOutput(stdout.toFile()).start(); if (process.waitFor(1, TimeUnit.SECONDS)) { result = process.exitValue() == 0; } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug(getStdoutMessage("The process timed out waiting for the response.", stdout)); } result = false; } } catch (IOException | InterruptedException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(getStdoutMessage("The process ended in error.", stdout), e); } result = false; } finally { if (process != null && process.isAlive()) { process.destroyForcibly(); } if (stdout != null) { try { Files.deleteIfExists(stdout); } catch (IOException ignore) { } } } return result; }
This works, however requires a new process to be created and launched which is not ideal.
It does look like there might be a $JAVA_HOME/release file which looks like a properties file with the JAVA_VERSION property. However we need to determine if all vendors include this file.
- causes
-
WFCORE-4383 DomainCommandBuilder ignores the specified PC/HC JVM
-
- Resolved
-
- relates to
-
WFMP-114 Failure using JDK 11
-
- Resolved
-