public class SInvocation
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SInvocation.AccessTestClass
Class used to test access level via ASM.
|
protected static class |
SInvocation.ExtendedClassWriter
Class writer with some meta information.
|
protected static class |
SInvocation.FallBackInvoker
Fallback invoker using reflection in case a byte-engineered variant is not available.
|
protected static class |
SInvocation.SortingInjectorWrapper |
Modifier and Type | Field and Description |
---|---|
protected static java.util.WeakHashMap<java.lang.Class<?>,WeakKeyValueMap<java.lang.Class<?>,java.lang.Class<?>>> |
ACCESSOR_CLASSES
Cached accessor classes.
|
static boolean |
DEFAULT_ACCESS
Flag if default / protected access via ASM is available.
|
protected static java.util.WeakHashMap<java.lang.Class<?>,WeakKeyValueMap<java.lang.Class<?>,java.lang.Class<?>>> |
EXTRACTOR_CLASSES
Cached extractor classes.
|
protected static java.util.WeakHashMap<java.lang.reflect.Method,java.lang.Class<IMethodInvoker>> |
INVOKER_CLASSES
Cached invoker classes, the invoker class does not prevent GC (tested).
|
static java.util.concurrent.atomic.AtomicLong |
NAME_SUFFIX_COUNTER
Class name suffix counter.
|
static boolean |
PRIVATE_ACCESS
Flag if private access via ASM is available.
|
Constructor and Description |
---|
SInvocation() |
Modifier and Type | Method and Description |
---|---|
static <T> java.lang.Class<T> |
createAccessorClass(IByteCodeClassLoader cl,
java.lang.Class<T> iface,
java.lang.Class<?> clazz)
Generates an accessor class based on an interface.
|
protected static SInvocation.ExtendedClassWriter |
createClass(java.lang.Class<?> targetclass,
java.lang.String classname,
int accesslevel,
java.lang.Class<?>... interfaces)
Creates the initial setup for a new class in ASM.
|
static java.lang.Class<IExtractor> |
createExtractorClass(IByteCodeClassLoader cl,
java.lang.Class<?> clazz,
java.lang.String[] propnames,
java.lang.reflect.Member[] accessormember)
Creates extractor class.
|
protected static <T> T |
createFallbackAccessor(java.lang.Class<T> iface,
java.lang.Class<?> clazz,
java.lang.Object obj)
Implements an accessor based on a dynamic proxy.
|
protected static java.lang.Class<IMethodInvoker> |
createInvokerClass(IByteCodeClassLoader cl,
java.lang.reflect.Method method)
Creates the invoker class.
|
protected static int |
determineAccessLevel(int currentlevel,
int modifiers)
Determines the necessary access level based on the current access level.
|
protected static void |
enableEnhancedAccess()
Tries to enable enhanced direct access.
|
static <T> java.lang.Class<T> |
getAccessorClass(java.lang.Class<T> iface,
java.lang.Class<?> targetclazz)
Gets class for an interface-based accessor.
|
static java.lang.Class<IMethodInvoker> |
getInvokerClass(java.lang.reflect.Method method)
Gets an invoker class.
|
static java.lang.Object |
invoke(java.lang.Object obj,
java.lang.Class<?> clazz,
java.lang.String methodname,
java.lang.Object... args)
Directly invokes a method based on the method name and arguments.
|
static java.lang.Object |
invoke(java.lang.Object obj,
java.lang.String methodname,
java.lang.Object... args)
Directly invokes a method based on the method name and arguments.
|
static <T> T |
newAccessor(java.lang.Class<T> iface,
java.lang.Class<?> targetclass,
java.lang.Object delegate)
Creates a new accessor from an accessor class.
|
static IExtractor |
newExtractor(java.lang.Class<IExtractor> extractorclass) |
protected static IMethodInvoker |
newInvoker(java.lang.Class<?> invokerclass)
Instantiate a new method invoker from the invoker class.
|
static IMethodInvoker |
newInvoker(java.lang.reflect.Method method)
Creates a new invoker for a method.
|
static IMethodInvoker |
newInvoker(java.lang.reflect.Method method,
IByteCodeClassLoader cl)
Creates a new invoker for a method.
|
protected static void |
prepareParameters(MethodVisitor mv,
java.lang.Class<?>[] parameters)
Readies the parameters for delegated method invocation.
|
public static java.util.concurrent.atomic.AtomicLong NAME_SUFFIX_COUNTER
public static boolean DEFAULT_ACCESS
public static boolean PRIVATE_ACCESS
protected static volatile java.util.WeakHashMap<java.lang.reflect.Method,java.lang.Class<IMethodInvoker>> INVOKER_CLASSES
protected static volatile java.util.WeakHashMap<java.lang.Class<?>,WeakKeyValueMap<java.lang.Class<?>,java.lang.Class<?>>> ACCESSOR_CLASSES
protected static volatile java.util.WeakHashMap<java.lang.Class<?>,WeakKeyValueMap<java.lang.Class<?>,java.lang.Class<?>>> EXTRACTOR_CLASSES
public static final java.lang.Object invoke(java.lang.Object obj, java.lang.String methodname, java.lang.Object... args)
obj
- Object on which the method is to be called.methodname
- Name of the methods.args
- Invocation arguments.public static final java.lang.Object invoke(java.lang.Object obj, java.lang.Class<?> clazz, java.lang.String methodname, java.lang.Object... args)
obj
- Object on which the method is to be called.clazz
- Class definition for static calls, can be null if obj is defined.methodname
- Name of the method.args
- Invocation arguments.public static final IMethodInvoker newInvoker(java.lang.reflect.Method method)
method
- The method.public static final IMethodInvoker newInvoker(java.lang.reflect.Method method, IByteCodeClassLoader cl)
method
- The method.cl
- ClassLoader to use.protected static final IMethodInvoker newInvoker(java.lang.Class<?> invokerclass)
invokerclass
- The invoker class.public static final java.lang.Class<IMethodInvoker> getInvokerClass(java.lang.reflect.Method method)
clazz
- The class used to map methods.methodidmap
- The method ID map to store the mapping.protected static final java.lang.Class<IMethodInvoker> createInvokerClass(IByteCodeClassLoader cl, java.lang.reflect.Method method)
cl
- ClassLoader to use for generated class.clazz
- The class used to map methods.public static final <T> T newAccessor(java.lang.Class<T> iface, java.lang.Class<?> targetclass, java.lang.Object delegate)
accessorclass
- The accessor class.delegate
- The delegation object / accessor target.public static final <T> java.lang.Class<T> getAccessorClass(java.lang.Class<T> iface, java.lang.Class<?> targetclazz)
iface
- The accessor interface.targetclazz
- The target class.public static final <T> java.lang.Class<T> createAccessorClass(IByteCodeClassLoader cl, java.lang.Class<T> iface, java.lang.Class<?> clazz)
cl
- The ClassLoader used to load the generated byte code.iface
- The accessor interface.clazz
- The target class of the accessor.public static final IExtractor newExtractor(java.lang.Class<IExtractor> extractorclass)
public static final java.lang.Class<IExtractor> createExtractorClass(IByteCodeClassLoader cl, java.lang.Class<?> clazz, java.lang.String[] propnames, java.lang.reflect.Member[] accessormember)
cl
- ClassLoader to use for generated class.clazz
- The class used to map methods.protected static final SInvocation.ExtendedClassWriter createClass(java.lang.Class<?> targetclass, java.lang.String classname, int accesslevel, java.lang.Class<?>... interfaces)
classname
- Simple name of the class.privileged
- If the class should be "privileged" to allow
access to non-publics.protected static final void prepareParameters(MethodVisitor mv, java.lang.Class<?>[] parameters)
mv
- The MethodVisitor being used.parameters
- The parameters of the method.protected static final int determineAccessLevel(int currentlevel, int modifiers)
currentlevel
- The current level.modifiers
- Modifiers of the targetprotected static final <T> T createFallbackAccessor(java.lang.Class<T> iface, java.lang.Class<?> clazz, java.lang.Object obj)
cl
- ClassLoader to use.iface
- The interface to implement.clazz
- The target class.obj
- The target class or null if all static.protected static final void enableEnhancedAccess()