|
@@ -1,5 +1,6 @@
|
|
|
package com.plugin.users.utils;
|
|
|
|
|
|
+import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
@@ -18,12 +19,19 @@ import java.net.URLClassLoader;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
public class ClassLoaderUtil {
|
|
|
+ private static Method method = Loader_addURL_Method();
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ private static Method Loader_addURL_Method() {
|
|
|
+ Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
|
|
|
+ if (!method.isAccessible()) {
|
|
|
+ method.setAccessible(true);
|
|
|
+ }
|
|
|
+ return method;
|
|
|
+ }
|
|
|
+
|
|
|
public static ClassLoader getClassLoader(String url) {
|
|
|
try {
|
|
|
- Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
|
|
|
- if (!method.isAccessible()) {
|
|
|
- method.setAccessible(true);
|
|
|
- }
|
|
|
URLClassLoader classLoader = new URLClassLoader(new URL[]{}, ClassLoaderUtil.class.getClassLoader());
|
|
|
method.invoke(classLoader, new URL(url));
|
|
|
return classLoader;
|