From 39427984d13f5ac1b4668592809366998ff8565c Mon Sep 17 00:00:00 2001 From: Karl Nelson Date: Fri, 29 Nov 2024 09:07:27 -0800 Subject: [PATCH] Another fix for (broken) Windows --- jpype/_core.py | 3 ++- native/java/org/jpype/JPypeClassLoader.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/jpype/_core.py b/jpype/_core.py index 5015ba782..0a5be9ead 100644 --- a/jpype/_core.py +++ b/jpype/_core.py @@ -324,10 +324,11 @@ def startJVM( # ok, setup the jpype system classloader and add to the path after startup # this guarentees all classes have the same permissions as they did in the past + from urllib.parse import quote extra_jvm_args += [ '-Djava.system.class.loader=org.jpype.JPypeClassLoader', '-Djava.class.path=%s'%support_lib, - '-Djpype.class.path=%s'%classpath, + '-Djpype.class.path=%s'%quote(classpath), '-Xshare:off' ] else: diff --git a/native/java/org/jpype/JPypeClassLoader.java b/native/java/org/jpype/JPypeClassLoader.java index 003284ecd..6e628780e 100644 --- a/native/java/org/jpype/JPypeClassLoader.java +++ b/native/java/org/jpype/JPypeClassLoader.java @@ -5,6 +5,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; @@ -26,6 +27,9 @@ import java.util.Set; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.net.URLDecoder; +import java.util.logging.Level; +import java.util.logging.Logger; public class JPypeClassLoader extends URLClassLoader { @@ -57,6 +61,14 @@ private static URL[] initial() String cp = System.getProperty("jpype.class.path"); if (cp == null) return new URL[0]; + + try + { + cp = URLDecoder.decode(cp, "UTF-8"); + } catch (UnsupportedEncodingException ex) + { + // ignored + } ArrayList path = new ArrayList<>(); int last = 0;