diff --git a/compiler/core/src/zserio/tools/ExtensionManager.java b/compiler/core/src/zserio/tools/ExtensionManager.java index 7b70bddd0..732545151 100644 --- a/compiler/core/src/zserio/tools/ExtensionManager.java +++ b/compiler/core/src/zserio/tools/ExtensionManager.java @@ -143,23 +143,10 @@ private File getWorkingDirectory() { try { - final String execUrlPath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); - final String decodedExecUrlPath = URLDecoder.decode(execUrlPath, "UTF-8"); - // check if decodedExecUrlPath is really URL, newer Java versions 11 or 17 returns normal path - System.out.println("decodedExecUrlPath = " + decodedExecUrlPath); - File decodedExecFile = null; - try - { - decodedExecFile = new File(new URI(decodedExecUrlPath)); - } - catch (URISyntaxException | IllegalArgumentException excpt) - { - decodedExecFile = new File(decodedExecUrlPath); - } - if (decodedExecFile.getPath().startsWith("file:")) - { - decodedExecFile = new File(decodedExecFile.getPath().replaceFirst("^file:", "")); - } + final URL execUrl = getClass().getProtectionDomain().getCodeSource().getLocation(); + System.out.println("execUrl = " + execUrl); + final String decodedExecUrlPath = URLDecoder.decode(execUrl.getPath(), "UTF-8"); + final File decodedExecFile = new File(new URI(decodedExecUrlPath)); System.out.println("decodedExecFile = " + decodedExecFile); System.out.println("decodedExecFile.getParentFile() = " + decodedExecFile.getParentFile()); @@ -168,7 +155,7 @@ private File getWorkingDirectory() return decodedExecFile.getParentFile(); } - catch (SecurityException | UnsupportedEncodingException excpt) + catch (SecurityException | URISyntaxException | UnsupportedEncodingException excpt) { return null; }