Package org.jboss.byteman.jigsaw
Class JigsawAccessEnabler
- java.lang.Object
-
- org.jboss.byteman.jigsaw.JigsawAccessEnabler
-
- All Implemented Interfaces:
AccessEnabler
public class JigsawAccessEnabler extends java.lang.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 Summary
Fields Modifier and Type Field Description boolean
DEBUG
flag to allow debug trace to be generatedprivate 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 Jigsawprivate java.util.Map<java.lang.String,java.util.Set<java.lang.Module>>
EMPTY_EXPORTS_MAP
empty exports set passed to an addExports callprivate java.util.Map<java.lang.String,java.util.Set<java.lang.Module>>
EMPTY_OPENS_MAP
empty opens set passed to an addExports callprivate java.util.Map<java.lang.Class<?>,java.util.List<java.lang.Class<?>>>
EMPTY_PROVIDES_MAP
empty provides map passed to an addExports callprivate java.util.Set<java.lang.Module>
EMPTY_READS_SET
empty reads set passed to an addExports callprivate java.util.Set<java.lang.Class<?>>
EMPTY_USES_SET
empty uses set passed to an addExports callprivate java.lang.instrument.Instrumentation
inst
the Instrumentation instance that allows addExports to be calledprivate java.lang.invoke.MethodHandles.Lookup
theLookup
private java.lang.Module
THIS_MODULE
the single Byteman module to which reflective access is granted by exporting packages as necessaryprivate java.util.Set<java.lang.Module>
THIS_MODULE_SET
singleton set passed to specify the single target module for an addExports callprivate java.lang.Module
UNPRIVILEGED_MODULE
the module to which the rest of the Byteman code belongs which should be the system or bootstrap unnamed module
-
Constructor Summary
Constructors Constructor Description JigsawAccessEnabler(java.lang.instrument.Instrumentation inst)
create an AccessEnabler that is capable of ensuring access when running inside a Jigsaw enabled JDK.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessibleConstructorInvoker
createConstructorInvoker(java.lang.reflect.Constructor constructor)
AccessibleFieldGetter
createFieldGetter(java.lang.reflect.Field field)
AccessibleFieldSetter
createFieldSetter(java.lang.reflect.Field field)
AccessibleMethodInvoker
createMethodInvoker(java.lang.reflect.Method method)
private void
debug(java.lang.String... args)
void
ensureAccess(java.lang.reflect.AccessibleObject accessible)
ensure that accessible can be accessed using reflection or a method handleprivate void
ensureModuleAccess(java.lang.reflect.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 packageboolean
requiresAccess(java.lang.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.boolean
requiresAccess(java.lang.reflect.AccessibleObject accessible)
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.
-
-
-
Field Detail
-
DEBUG
public boolean DEBUG
flag to allow debug trace to be generated
-
THIS_MODULE
private java.lang.Module THIS_MODULE
the single Byteman module to which reflective access is granted by exporting packages as necessary
-
UNPRIVILEGED_MODULE
private java.lang.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 java.util.Set<java.lang.Module> THIS_MODULE_SET
singleton set passed to specify the single target module for an addExports call
-
EMPTY_READS_SET
private java.util.Set<java.lang.Module> EMPTY_READS_SET
empty reads set passed to an addExports call
-
EMPTY_EXPORTS_MAP
private java.util.Map<java.lang.String,java.util.Set<java.lang.Module>> EMPTY_EXPORTS_MAP
empty exports set passed to an addExports call
-
EMPTY_OPENS_MAP
private java.util.Map<java.lang.String,java.util.Set<java.lang.Module>> EMPTY_OPENS_MAP
empty opens set passed to an addExports call
-
EMPTY_USES_SET
private java.util.Set<java.lang.Class<?>> EMPTY_USES_SET
empty uses set passed to an addExports call
-
EMPTY_PROVIDES_MAP
private java.util.Map<java.lang.Class<?>,java.util.List<java.lang.Class<?>>> EMPTY_PROVIDES_MAP
empty provides map passed to an addExports call
-
inst
private java.lang.instrument.Instrumentation inst
the Instrumentation instance that allows addExports to be called
-
theLookup
private java.lang.invoke.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 Detail
-
JigsawAccessEnabler
public JigsawAccessEnabler(java.lang.instrument.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 Detail
-
requiresAccess
public boolean requiresAccess(java.lang.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 interfaceAccessEnabler
- 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(java.lang.reflect.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 interfaceAccessEnabler
- 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(java.lang.reflect.AccessibleObject accessible)
ensure that accessible can be accessed using reflection or a method handle- Specified by:
ensureAccess
in interfaceAccessEnabler
- Parameters:
accessible
- this must be a Member
-
createMethodInvoker
public AccessibleMethodInvoker createMethodInvoker(java.lang.reflect.Method method)
- Specified by:
createMethodInvoker
in interfaceAccessEnabler
-
createConstructorInvoker
public AccessibleConstructorInvoker createConstructorInvoker(java.lang.reflect.Constructor constructor)
- Specified by:
createConstructorInvoker
in interfaceAccessEnabler
-
createFieldGetter
public AccessibleFieldGetter createFieldGetter(java.lang.reflect.Field field)
- Specified by:
createFieldGetter
in interfaceAccessEnabler
-
createFieldSetter
public AccessibleFieldSetter createFieldSetter(java.lang.reflect.Field field)
- Specified by:
createFieldSetter
in interfaceAccessEnabler
-
ensureModuleAccess
private void ensureModuleAccess(java.lang.reflect.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(java.lang.String... args)
-
-