For one of my projects, I decided to create "plugin" system to load class at runtime from JAR files. Currently, I load each plugin using URLClassLoader.

With arrival of JDK9, is there any plans for loading modules at runtime (or is available already for testing in build snapshots)? For example instead of:

String pluginPath = "CPU_Monitor.jar";

URL pluginUrl = new URL(pluginPath);

URL[] urls = {pluginUrl};

URLClassLoader urlClassLoader = new URLClassLoader(urls);

Class<?> pluginClass = urlClassLoader.findClass("com.example.cpu.monitoring.Monitor");


Would be possible to use something like this:

Module pluginModule = ModuleManager.getModule("com.example.cpu.Monitoring");

Class<?> pluginClass = pluginModule.getClass("com.example.cpu.monitoring.Monitor");


I guess that something like this could be implemented as library outside JDK, but such API could be great addition to Jigsaw.

Reply via email to