Class JigsawAccessEnabler

java.lang.Object
org.jboss.byteman.jigsaw.JigsawAccessEnabler
All Implemented Interfaces:
AccessEnabler

public class JigsawAccessEnabler extends Object implements AccessEnabler
Implementation of AccessEnabler for use in a Jigsaw enabled JDK runtime n.b. this class is only exemplary and must not be compiled into the Byteman jar. It is supposed to be generated at runtime and installed by the classloader for the org.jboss.byteman.jigsaw module created by the LayerFactory.
  • Field Details

    • DEBUG

      public boolean DEBUG
      flag to allow debug trace to be generated
    • THIS_MODULE

      private Module THIS_MODULE
      the single Byteman module to which reflective access is granted by exporting packages as necessary
    • UNPRIVILEGED_MODULE

      private Module UNPRIVILEGED_MODULE
      the module to which the rest of the Byteman code belongs which should be the system or bootstrap unnamed module
    • THIS_MODULE_SET

      private Set<Module> THIS_MODULE_SET
      singleton set passed to specify the single target module for an addExports call
    • EMPTY_READS_SET

      private Set<Module> EMPTY_READS_SET
      empty reads set passed to an addExports call
    • EMPTY_EXPORTS_MAP

      private Map<String,Set<Module>> EMPTY_EXPORTS_MAP
      empty exports set passed to an addExports call
    • EMPTY_OPENS_MAP

      private Map<String,Set<Module>> EMPTY_OPENS_MAP
      empty opens set passed to an addExports call
    • EMPTY_USES_SET

      private Set<Class<?>> EMPTY_USES_SET
      empty uses set passed to an addExports call
    • EMPTY_PROVIDES_MAP

      private Map<Class<?>,List<Class<?>>> EMPTY_PROVIDES_MAP
      empty provides map passed to an addExports call
    • inst

      private Instrumentation inst
      the Instrumentation instance that allows addExports to be called
    • theLookup

      private MethodHandles.Lookup theLookup
    • defaultAccessEnabler

      private DefaultAccessEnabler defaultAccessEnabler
      default enabler to provide reflective access in cases where we run up against an IllegalAccessException for java.base classes because of the current rather extreme restrictions provided by Jigsaw
  • Constructor Details

    • JigsawAccessEnabler

      public JigsawAccessEnabler(Instrumentation inst)
      create an AccessEnabler that is capable of ensuring access when running inside a Jigsaw enabled JDK. This constructor throws an exception if it is not provided with a non-null Instrumentation instance as argument, effectively limiting the use of this class to JVMTI agents.
      Parameters:
      inst - the instrumentation instance we need to use to enable access
  • Method Details

    • requiresAccess

      public boolean requiresAccess(Class<?> klazz)
      test whether reference to the class from a classpath class requires the use of reflection or a method handle and possibly also module jiggery-pokery.
      Specified by:
      requiresAccess in interface AccessEnabler
      Parameters:
      klazz - the class to be checked
      Returns:
      true if reference to the class from a classpath class requires the use of reflection or a method handle and possibly module jiggery-pokery otherwise false.
    • requiresAccess

      public boolean requiresAccess(AccessibleObject accessible)
      Description copied from interface: AccessEnabler
      test whether access to the accessible from a classpath class requires the use of reflection or a method handle and possibly also module jiggery-pokery.
      Specified by:
      requiresAccess in interface AccessEnabler
      Parameters:
      accessible - this must be a Member
      Returns:
      true if access requires reflection or a method handle and possibly also module jiggery-pokery otherwise false.
    • ensureAccess

      public void ensureAccess(AccessibleObject accessible)
      ensure that accessible can be accessed using reflection or a method handle
      Specified by:
      ensureAccess in interface AccessEnabler
      Parameters:
      accessible - this must be a Member
    • createMethodInvoker

      public AccessibleMethodInvoker createMethodInvoker(Method method)
      Specified by:
      createMethodInvoker in interface AccessEnabler
    • createConstructorInvoker

      public AccessibleConstructorInvoker createConstructorInvoker(Constructor constructor)
      Specified by:
      createConstructorInvoker in interface AccessEnabler
    • createFieldGetter

      public AccessibleFieldGetter createFieldGetter(Field field)
      Specified by:
      createFieldGetter in interface AccessEnabler
    • createFieldSetter

      public AccessibleFieldSetter createFieldSetter(Field field)
      Specified by:
      createFieldSetter in interface AccessEnabler
    • ensureModuleAccess

      private void ensureModuleAccess(AccessibleObject accessible)
      check whether the accessible's owning class resides in a non-default module and if so ensure that the package is exported to the Byteman Jigsaw package
      Parameters:
      accessible -
    • debug

      private void debug(String... args)