diff --git a/compiler/core/src/zserio/tools/ExtensionManager.java b/compiler/core/src/zserio/tools/ExtensionManager.java index 0d0534366..f0157c377 100644 --- a/compiler/core/src/zserio/tools/ExtensionManager.java +++ b/compiler/core/src/zserio/tools/ExtensionManager.java @@ -6,6 +6,7 @@ import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; import java.net.URLDecoder; @@ -105,11 +106,11 @@ public void callExtensions(Root rootNode, ExtensionParameters parameters) throws private ClassLoader getClassLoader() { final ClassLoader currentClassLoader = getClass().getClassLoader(); - final String workingDirectory = getWorkingDirectory(); + final File workingDirectory = getWorkingDirectory(); if (workingDirectory == null) return currentClassLoader; - final File[] fileList = new File(workingDirectory).listFiles(); + final File[] fileList = workingDirectory.listFiles(); if (fileList == null) return currentClassLoader; @@ -136,17 +137,19 @@ private ClassLoader getClassLoader() return urlClassLoader; } - private String getWorkingDirectory() + private File getWorkingDirectory() { try { final String execPath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); final String decodedExecPath = URLDecoder.decode(execPath, "UTF-8"); - final String workingDirectory = new File(decodedExecPath).getParent(); + final String workingDirectoryUrl = new File(decodedExecPath).getParent(); + final File workingDirectory = new File(new URL(workingDirectoryUrl).toURI()); return workingDirectory; } - catch (SecurityException | UnsupportedEncodingException excpt) + catch (SecurityException | UnsupportedEncodingException | MalformedURLException | + URISyntaxException excpt) { return null; }