java.lang.Object
org.apache.commons.jexl3.internal.introspection.ClassTool

class ClassTool extends Object
Utility for Java9+ backport in Java8 of class and module related methods.
  • Field Details

    • GET_MODULE

      private static final MethodHandle GET_MODULE
      The Class.getModule() method.
    • GET_PKGNAME

      private static final MethodHandle GET_PKGNAME
      The Class.getPackageName() method.
    • IS_EXPORTED

      private static final MethodHandle IS_EXPORTED
      The Module.isExported(String packageName) method.
  • Constructor Details

    • ClassTool

      ClassTool()
  • Method Details

    • isExported

      static boolean isExported(Class<?> declarator)
      Checks whether a class is exported by its module (java 9+). The code performs the following sequence through reflection (since the same jar can run on a Java8 or Java9+ runtime and the module features does not exist on 8). Module module = declarator.getModule(); return module.isExported(declarator.getPackageName()); This is required since some classes and methods may not be exported thus not callable through reflection.
      Parameters:
      declarator - the class
      Returns:
      true if class is exported or no module support exists
    • getPackageName

      static String getPackageName(Class<?> clz)
      Gets the package name of a class (class.getPackage() may return null).
      Parameters:
      clz - the class
      Returns:
      the class package name