Package org.jboss.byteman.jigsaw
Class JigsawAccessEnabler
java.lang.Object
org.jboss.byteman.jigsaw.JigsawAccessEnabler
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionbooleanflag to allow debug trace to be generatedprivate DefaultAccessEnablerdefault 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 Jigsawempty exports set passed to an addExports callempty opens set passed to an addExports callempty provides map passed to an addExports callempty reads set passed to an addExports callempty uses set passed to an addExports callprivate Instrumentationthe Instrumentation instance that allows addExports to be calledprivate MethodHandles.Lookupprivate Modulethe single Byteman module to which reflective access is granted by exporting packages as necessarysingleton set passed to specify the single target module for an addExports callprivate Modulethe module to which the rest of the Byteman code belongs which should be the system or bootstrap unnamed module -
Constructor Summary
ConstructorsConstructorDescriptioncreate an AccessEnabler that is capable of ensuring access when running inside a Jigsaw enabled JDK. -
Method Summary
Modifier and TypeMethodDescriptioncreateConstructorInvoker(Constructor constructor) createFieldGetter(Field field) createFieldSetter(Field field) createMethodInvoker(Method method) private voidvoidensureAccess(AccessibleObject accessible) ensure that accessible can be accessed using reflection or a method handleprivate voidensureModuleAccess(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 packagebooleanrequiresAccess(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.booleanrequiresAccess(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 Details
-
DEBUG
public boolean DEBUGflag to allow debug trace to be generated -
THIS_MODULE
the single Byteman module to which reflective access is granted by exporting packages as necessary -
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
singleton set passed to specify the single target module for an addExports call -
EMPTY_READS_SET
empty reads set passed to an addExports call -
EMPTY_EXPORTS_MAP
empty exports set passed to an addExports call -
EMPTY_OPENS_MAP
empty opens set passed to an addExports call -
EMPTY_USES_SET
empty uses set passed to an addExports call -
EMPTY_PROVIDES_MAP
empty provides map passed to an addExports call -
inst
the Instrumentation instance that allows addExports to be called -
theLookup
-
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
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
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:
requiresAccessin 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
Description copied from interface:AccessEnablertest 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:
requiresAccessin 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
ensure that accessible can be accessed using reflection or a method handle- Specified by:
ensureAccessin interfaceAccessEnabler- Parameters:
accessible- this must be a Member
-
createMethodInvoker
- Specified by:
createMethodInvokerin interfaceAccessEnabler
-
createConstructorInvoker
- Specified by:
createConstructorInvokerin interfaceAccessEnabler
-
createFieldGetter
- Specified by:
createFieldGetterin interfaceAccessEnabler
-
createFieldSetter
- Specified by:
createFieldSetterin interfaceAccessEnabler
-
ensureModuleAccess
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
-