public final class ModuleSupport extends Object
Modifier and Type | Method and Description |
---|---|
static void |
exportAndOpenAllPackagesToUnnamed(String name,
boolean optional)
Exports and opens all packages in the module named
name to all unnamed modules. |
static void |
exportAndOpenPackageToClass(String moduleName,
String packageName,
boolean optional,
Class<?> accessingClass)
Exports and opens a single package
packageName in the module named moduleName
to all unnamed modules. |
static void |
exportAndOpenPackageToUnnamed(String name,
String pkg,
boolean optional)
Exports and opens
pkg in the module named name to all unnamed modules. |
static void |
findResourcesInModules(Predicate<String> resourceNameFilter,
BiConsumer<String,InputStream> operation)
In the modules of the boot module layer, filters all resources that match the given
predicate, and calls the operation on the matched resources.
|
static String |
getModuleName(Class<?> clazz)
Gets the name of the module containing
clazz . |
static List<String> |
getModuleResources(Collection<Path> modulePath)
Gets all resources in the modules named by
modules from the Java runtime image. |
static ResourceBundle |
getResourceBundle(String bundleName,
Locale locale,
ClassLoader loader) |
static List<String> |
getSystemModuleResources(Collection<String> names) |
static boolean |
hasSystemModule(String moduleName)
Checks if the Java run-time image contains a module with the given name.
|
static void |
openModuleByClass(Class<?> declaringClass,
Class<?> accessingClass)
Add the proper module opening to allow accesses from accessingClass to declaringClass.
|
public static ResourceBundle getResourceBundle(String bundleName, Locale locale, ClassLoader loader)
public static boolean hasSystemModule(String moduleName)
public static List<String> getModuleResources(Collection<Path> modulePath)
modules
from the Java runtime image.public static List<String> getSystemModuleResources(Collection<String> names)
public static void openModuleByClass(Class<?> declaringClass, Class<?> accessingClass)
public static void exportAndOpenPackageToClass(String moduleName, String packageName, boolean optional, Class<?> accessingClass)
packageName
in the module named moduleName
to all unnamed modules.public static void exportAndOpenAllPackagesToUnnamed(String name, boolean optional)
name
to all unnamed modules.optional
- if false
and there is no module named name
,
NoSuchElementException
is thrownpublic static void exportAndOpenPackageToUnnamed(String name, String pkg, boolean optional)
pkg
in the module named name
to all unnamed modules.optional
- if false
and there is no module named name
,
NoSuchElementException
is thrownpublic static String getModuleName(Class<?> clazz)
clazz
.public static void findResourcesInModules(Predicate<String> resourceNameFilter, BiConsumer<String,InputStream> operation) throws IOException
resourceNameFilter
- predicate applied to all resource names in the moduleoperation
- a function to process matched resources, it receives the name of the
resources as the first argument and an open stream as the second argumentIOException