File tree Expand file tree Collapse file tree 4 files changed +20
-5
lines changed
src/main/java/org/mangorage/bootstrap Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 44
55import java .io .IOException ;
66import java .nio .file .Path ;
7- import java .util .List ;
87
98import static org .mangorage .bootstrap .internal .Util .*;
109
@@ -35,6 +34,6 @@ public static void main(String[] args) throws IOException {
3534 }
3635 });
3736
38- callMain (cfg .getMainClass (), args , cl );
37+ callMain (cfg .getMainClass (), args , moduleLayer . findModule ( "org.mangorage.mangobotcore" ). get () );
3938 }
4039}
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ public ClassLoader constructClassloaders() {
117117
118118 // Create a new URLClassLoader with the current folder URL and the parent
119119 URL [] urls = Util .fetchJars (new File []{folderFile });
120- currentClassLoader = new URLClassLoader (urls , parentClassLoader );
120+ currentClassLoader = new MangoLoader (urls , parentClassLoader );
121121
122122 // The newly created classloader becomes the parent for the next iteration
123123 parentClassLoader = currentClassLoader ;
Original file line number Diff line number Diff line change 1+ package org .mangorage .bootstrap .internal ;
2+
3+ import java .io .IOException ;
4+ import java .net .URL ;
5+ import java .net .URLClassLoader ;
6+
7+ public final class MangoLoader extends URLClassLoader {
8+ public MangoLoader (URL [] urls , ClassLoader parent ) {
9+ super (urls , parent );
10+ }
11+
12+ @ Override
13+ protected URL findResource (String moduleName , String name ) throws IOException {
14+ return super .findResource (name );
15+ }
16+ }
Original file line number Diff line number Diff line change @@ -86,9 +86,9 @@ public static String getModuleName(File jarFile) {
8686 return null ; // Jar was either not modular or you're just unlucky
8787 }
8888
89- public static void callMain (String className , String [] args , ClassLoader classLoader ) {
89+ public static void callMain (String className , String [] args , Module module ) {
9090 try {
91- Class <?> clazz = Class .forName (className , false , classLoader );
91+ Class <?> clazz = Class .forName (className , false , module . getClassLoader () );
9292 Method mainMethod = clazz .getMethod ("main" , String [].class );
9393
9494 // Make sure it's static and public
You can’t perform that action at this time.
0 commit comments