Changes
parent
b6b8579507
commit
719f3e8ed0
|
@ -0,0 +1,23 @@
|
|||
package rule.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ExternalClassLoader extends URLClassLoader {
|
||||
|
||||
public ExternalClassLoader(URL[] urls) {
|
||||
super(urls, Thread.currentThread().getContextClassLoader());
|
||||
}
|
||||
|
||||
public Class<?> defineClassFromBytes(byte[] classBytes, String className) throws IOException {
|
||||
return super.defineClass(className, classBytes, 0, classBytes.length);
|
||||
}
|
||||
|
||||
public Class<?> loadClassFromPath(Path classFilePath, String className) throws IOException {
|
||||
byte[] classData = Files.readAllBytes(classFilePath);
|
||||
return defineClassFromBytes(classData, className);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue