protected void loadModules ( String sourceDir , Collection < String > moduleNames ) { ModuleFinder finder = ModuleFinder . of ( Paths . get ( sourceDir ) ) ; ClassLoader scl = ClassLoader . getSystemClassLoader ( ) ; ModuleLayer parent = ModuleLayer . boot ( ) ; Configuration cf = parent . configuration ( ) . resolve ( finder , ModuleFinder . of ( ) , moduleNames ) ; layer = parent . defineModulesWithOneLoader ( cf , scl ) ; }
Load all the modules that were configured into the main class loader we don t want any additional class loaders we just want to load the classes in .