From c2e4ee2f00f531ad2b744fe301687afcd5ea6faa Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 10 Mar 2023 10:07:17 +0100 Subject: [PATCH] Fix EnvHelper#chDir on JDK 21 (#802) --- daemon/src/main/java/org/mvndaemon/mvnd/cli/EnvHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/cli/EnvHelper.java b/daemon/src/main/java/org/mvndaemon/mvnd/cli/EnvHelper.java index 3ed9e3055..cfb83d81c 100644 --- a/daemon/src/main/java/org/mvndaemon/mvnd/cli/EnvHelper.java +++ b/daemon/src/main/java/org/mvndaemon/mvnd/cli/EnvHelper.java @@ -114,7 +114,7 @@ static void chDir(String workingDir) throws Exception { // change current dir for the java.io.File class Class fileClass = Class.forName("java.io.File"); if (JavaVersion.getJavaSpec() >= 11.0) { - Field fsField = fileClass.getDeclaredField("fs"); + Field fsField = fileClass.getDeclaredField(JavaVersion.getJavaSpec() >= 21.0 ? "FS" : "fs"); fsField.setAccessible(true); Object fs = fsField.get(null); Field userDirField = fs.getClass().getDeclaredField("userDir");