diff --git a/build.gradle b/build.gradle index b3a6be6..28a758a 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ repositories { } dependencies { - implementation group: 'com.google.inject', name: 'guice', version: '4.2.2' + implementation group: 'com.google.inject', name: 'guice', version: '5.1.0' implementation group: 'com.google.guava', name: 'guava', version: '31.0.1-jre' implementation group: 'com.moandjiezana.toml', name: 'toml4j', version: '0.7.2' implementation group: 'info.picocli', name: 'picocli', version: '4.1.4' diff --git a/src/main/java/com/scalar/kelpie/modules/ModuleLoader.java b/src/main/java/com/scalar/kelpie/modules/ModuleLoader.java index 74422b9..48e858f 100644 --- a/src/main/java/com/scalar/kelpie/modules/ModuleLoader.java +++ b/src/main/java/com/scalar/kelpie/modules/ModuleLoader.java @@ -67,11 +67,9 @@ public List loadInjectors() throws ModuleLoadException { private Module loadModule(String className, String jarPath) throws ModuleLoadException { try { - URLClassLoader classLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader(); URL jarUrl = new File(jarPath).toURI().toURL(); - Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - method.setAccessible(true); - method.invoke(classLoader, jarUrl); + URLClassLoader classLoader = new URLClassLoader(new URL[] { jarUrl }, Thread.currentThread().getContextClassLoader()); + Thread.currentThread().setContextClassLoader(classLoader); @SuppressWarnings("unchecked") Class clazz = (Class) Class.forName(className, true, classLoader);