diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2023-06-17 00:52:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-17 00:52:41 +0200 |
commit | 689ebd8e2bc1f046a4b6f7aeb9c2bc2d8522b309 (patch) | |
tree | 2ababb089fc82e1cec1fa70e1cfc46a5b00dd1ab /src/main/java/kubatech/api/helpers/ReflectionHelper.java | |
parent | cb383c824c3f799e678fb98f29661d79b5a13836 (diff) | |
download | GT5-Unofficial-689ebd8e2bc1f046a4b6f7aeb9c2bc2d8522b309.tar.gz GT5-Unofficial-689ebd8e2bc1f046a4b6f7aeb9c2bc2d8522b309.tar.bz2 GT5-Unofficial-689ebd8e2bc1f046a4b6f7aeb9c2bc2d8522b309.zip |
Fix crash when there are spaces in the game path (#78)
Diffstat (limited to 'src/main/java/kubatech/api/helpers/ReflectionHelper.java')
-rw-r--r-- | src/main/java/kubatech/api/helpers/ReflectionHelper.java | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/main/java/kubatech/api/helpers/ReflectionHelper.java b/src/main/java/kubatech/api/helpers/ReflectionHelper.java index 8f2234f052..91b785d7fb 100644 --- a/src/main/java/kubatech/api/helpers/ReflectionHelper.java +++ b/src/main/java/kubatech/api/helpers/ReflectionHelper.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.net.JarURLConnection; import java.net.URL; import java.util.Collection; import java.util.Collections; @@ -161,7 +162,7 @@ public class ReflectionHelper { * @param packageName The package name * @return The class nodes */ - public static Collection<ClassNode> getClasses(String packageName) throws IOException, SecurityException { + public static Collection<ClassNode> getClasses(String packageName) throws IOException { ClassLoader classLoader = Thread.currentThread() .getContextClassLoader(); assert classLoader != null; @@ -170,9 +171,7 @@ public class ReflectionHelper { if (resource == null) throw new FileNotFoundException(); if (!resource.getProtocol() .equals("jar")) return Collections.emptySet(); - String jarPath = resource.getPath(); - - try (JarFile jar = new JarFile(jarPath.substring(5, jarPath.indexOf('!')))) { + try (JarFile jar = ((JarURLConnection) resource.openConnection()).getJarFile()) { return jar.stream() .filter( j -> !j.isDirectory() && j.getName() |