Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package bla;
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
import java.nio.file.Path;
import java.util.Set;
public class SampleLayer {
public static void main(String[] args) throws ClassNotFoundException {
Path[] paths = { Path.of("/Users/tomschindl/SDKs/javafx-sdk-11.0.2/lib/javafx.base.jar") };
ModuleLayer boot = ModuleLayer.boot();
Configuration cfg = boot.configuration();
ModuleFinder finder = ModuleFinder.of(paths);
Configuration resolve = cfg.resolve(finder, ModuleFinder.of(), Set.of("javafx.base"));
ModuleLayer moduleLayer = boot.defineModulesWithOneLoader(resolve, ClassLoader.getSystemClassLoader());
System.err.println(moduleLayer.modules());
ClassLoader loader = moduleLayer.findLoader("javafx.base");
System.err.println(loader);
Class<?> cl1 = loader.loadClass("javafx.beans.property.Property");
moduleLayer = boot.defineModulesWithOneLoader(resolve, ClassLoader.getSystemClassLoader());
System.err.println(moduleLayer.modules());
loader = moduleLayer.findLoader("javafx.base");
System.err.println(loader);
Class<?> cl2 = loader.loadClass("javafx.beans.property.Property");
System.err.println(cl1 == cl2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment