Class ModuleUtils


  • @API(status=INTERNAL,
         since="1.1")
    public class ModuleUtils
    extends java.lang.Object
    Collection of utilities for working with java.lang.Module and friends.

    DISCLAIMER

    These utilities are intended solely for usage within the JUnit framework itself. Any usage by external parties is not supported. Use at your own risk!

    Since:
    1.1
    • Constructor Summary

      Constructors 
      Constructor Description
      ModuleUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.lang.Class<?>> findAllClassesInModule​(java.lang.String moduleName, ClassFilter filter)
      Find all classes for the given module name.
      static java.util.Set<java.lang.String> findAllNonSystemBootModuleNames()
      Find all non-system boot modules names.
      static java.util.Optional<java.lang.String> getModuleName​(java.lang.Class<?> type)
      Return the name of the module that the class or interface is a member of.
      static java.util.Optional<java.lang.String> getModuleVersion​(java.lang.Class<?> type)
      Return the raw version of the module that the class or interface is a member of.
      static boolean isJavaPlatformModuleSystemAvailable()
      Determine if the current Java runtime supports the Java Platform Module System.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ModuleUtils

        public ModuleUtils()
    • Method Detail

      • findAllNonSystemBootModuleNames

        public static java.util.Set<java.lang.String> findAllNonSystemBootModuleNames()
        Find all non-system boot modules names.
        Returns:
        a set of all such module names; never null but potentially empty
      • isJavaPlatformModuleSystemAvailable

        public static boolean isJavaPlatformModuleSystemAvailable()
        Determine if the current Java runtime supports the Java Platform Module System.
        Returns:
        true if the Java Platform Module System is available, otherwise false
      • getModuleName

        public static java.util.Optional<java.lang.String> getModuleName​(java.lang.Class<?> type)
        Return the name of the module that the class or interface is a member of.
        Parameters:
        type - class or interface to analyze
        Returns:
        the module name; never null but potentially empty
      • getModuleVersion

        public static java.util.Optional<java.lang.String> getModuleVersion​(java.lang.Class<?> type)
        Return the raw version of the module that the class or interface is a member of.
        Parameters:
        type - class or interface to analyze
        Returns:
        the raw module version; never null but potentially empty
      • findAllClassesInModule

        public static java.util.List<java.lang.Class<?>> findAllClassesInModule​(java.lang.String moduleName,
                                                                                ClassFilter filter)
        Find all classes for the given module name.
        Parameters:
        moduleName - the name of the module to scan; never null or empty
        filter - the class filter to apply; never null
        Returns:
        an immutable list of all such classes found; never null but potentially empty