Class ModuleLayerHelper


  • public class ModuleLayerHelper
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Optional<java.lang.Object> getBootModuleLayer()
      A ModuleLayer needs to be provided for the ReflectionTypeSolver and the boot layer (the module layer containing the module `java.base`) is chosen as a default.
      static java.util.HashMap<java.lang.String,​java.util.Set<java.lang.String>> getModulePackagesFromLayers​(java.lang.Iterable<java.lang.Object> moduleLayers)
      The JDK doesn't expose a simple mechanism for listing modules containing classes loaded by a classloader, so users who would like to solve types in modules need to provide a list of module layers containing the modules that should be discoverable by the type solver.
      • Methods inherited from class java.lang.Object

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

      • ModuleLayerHelper

        public ModuleLayerHelper()
    • Method Detail

      • getModulePackagesFromLayers

        public static java.util.HashMap<java.lang.String,​java.util.Set<java.lang.String>> getModulePackagesFromLayers​(java.lang.Iterable<java.lang.Object> moduleLayers)
        The JDK doesn't expose a simple mechanism for listing modules containing classes loaded by a classloader, so users who would like to solve types in modules need to provide a list of module layers containing the modules that should be discoverable by the type solver.
        To maintain compatibility with Java 8, the ModuleLayer and Module classes introduced in Java 9 cannot be used, so reflection and the Object type are used instead.
        Note: JavaParser currently does not support the exports...to... feature since necessary state information to handle this correctly is not tracked. If such support is added in the future, the signature of this method may change to include the extra information.
        Parameters:
        moduleLayers - a list of java.lang.ModuleLayer instances that should be used for type solving
        Returns:
        a map of ModuleName->ExportedPackages
      • getBootModuleLayer

        public static java.util.Optional<java.lang.Object> getBootModuleLayer()
        A ModuleLayer needs to be provided for the ReflectionTypeSolver and the boot layer (the module layer containing the module `java.base`) is chosen as a default. There may be advanced cases where this assumption is incorrect. In these cases, the ClassLoaderTypeSolver should be used instead.
        Returns:
        the boot module layer, if it exists (i.e. on Java > 9)