/** * Get the module for a loaded class, or {@code null} if the class did not come from any module. * * @param clazz the class * @return the module it came from */ public static Module forClass(Class<?> clazz) { final ClassLoader cl = clazz.getClassLoader(); return forClassLoader(cl, false); }
/** * Get the module for a loaded class, or {@code null} if the class did not come from any module. * * @param clazz the class * @return the module it came from */ public static Module forClass(Class<?> clazz) { final ClassLoader cl = clazz.getClassLoader(); return forClassLoader(cl, false); }
/** * Get the current thread's context module loader. This loader is the one which defined the module * whose class loader is, or is a parent of, the thread's current context class loader. If there is none, * then {@code null} is returned. * * @return the module loader, or {@code null} if none is set */ public static ModuleLoader getContextModuleLoader() { return Module.forClassLoader(Thread.currentThread().getContextClassLoader(), true).getModuleLoader(); }
/** * Get the current thread's context module loader. This loader is the one which defined the module * whose class loader is, or is a parent of, the thread's current context class loader. If there is none, * then {@code null} is returned. * * @return the module loader, or {@code null} if none is set */ public static ModuleLoader getContextModuleLoader() { return Module.forClassLoader(Thread.currentThread().getContextClassLoader(), true).getModuleLoader(); }
/** * Get the module loader for a class loader. * * @param classLoader the class loader * * @return the module loader or {@code null} if the class loader does not belong to a module loader. */ public static ModuleLoader forClassLoader(ClassLoader classLoader) { final Module module = Module.forClassLoader(classLoader, true); if (module == null) { return null; } return module.getModuleLoader(); }
/** * Get the module loader for a class loader. * * @param classLoader the class loader * * @return the module loader or {@code null} if the class loader does not belong to a module loader. */ public static ModuleLoader forClassLoader(ClassLoader classLoader) { final Module module = Module.forClassLoader(classLoader, true); if (module == null) { return null; } return module.getModuleLoader(); }
/** * Get the module for a class loader, or {@code null} if the class loader is not associated with any module. If * the class loader is unknown, it is possible to check the parent class loader up the chain, and so on until a module is found. * * @param cl the class loader * @param search {@code true} to search up the delegation chain * @return the associated module */ public static Module forClassLoader(ClassLoader cl, boolean search) { if (cl instanceof ModuleClassLoader) { return ((ModuleClassLoader) cl).getModule(); } else if (search && cl != null) { return forClassLoader(cl.getParent(), true); } else { return null; } }
/** * Get the module for a class loader, or {@code null} if the class loader is not associated with any module. If * the class loader is unknown, it is possible to check the parent class loader up the chain, and so on until a module is found. * * @param cl the class loader * @param search {@code true} to search up the delegation chain * @return the associated module */ public static Module forClassLoader(ClassLoader cl, boolean search) { if (cl instanceof ModuleClassLoader) { return ((ModuleClassLoader) cl).getModule(); } else if (search) { return forClassLoader(cl.getParent(), true); } else { return null; } }
Module module = Module.forClassLoader(moduleclassLoader, true); if (module == null)
composite.add(Module.forClassLoader(Bootstrap.class.getClassLoader(), true).getClassLoader());
Module module = Module.forClassLoader(classLoader, true); ModuleIdentifier moduleIdentifier = module.getIdentifier(); ServiceName moduleServiceName = ServiceModuleLoader.moduleServiceName(moduleIdentifier);