Package jadex.bytecode.invocation
Class SInvocation
- java.lang.Object
- 
- jadex.bytecode.invocation.SInvocation
 
- 
 public class SInvocation extends java.lang.ObjectFactory for providing fast reflective access to methods.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classSInvocation.AccessTestClassClass used to test access level via ASM.protected static classSInvocation.ExtendedClassWriterClass writer with some meta information.protected static classSInvocation.FallBackInvokerFallback invoker using reflection in case a byte-engineered variant is not available.protected static classSInvocation.SortingInjectorWrapper
 - 
Field SummaryFields Modifier and Type Field Description protected static java.util.WeakHashMap<java.lang.Class<?>,WeakKeyValueMap<java.lang.Class<?>,java.lang.Class<?>>>ACCESSOR_CLASSESCached accessor classes.static booleanDEFAULT_ACCESSFlag if default / protected access via ASM is available.protected static java.util.WeakHashMap<java.lang.Class<?>,WeakKeyValueMap<java.lang.Class<?>,java.lang.Class<?>>>EXTRACTOR_CLASSESCached extractor classes.protected static java.util.WeakHashMap<java.lang.reflect.Method,java.lang.Class<IMethodInvoker>>INVOKER_CLASSESCached invoker classes, the invoker class does not prevent GC (tested).static java.util.concurrent.atomic.AtomicLongNAME_SUFFIX_COUNTERClass name suffix counter.static booleanPRIVATE_ACCESSFlag if private access via ASM is available.
 - 
Constructor SummaryConstructors Constructor Description SInvocation()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method 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.ExtendedClassWritercreateClass(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> TcreateFallbackAccessor(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 intdetermineAccessLevel(int currentlevel, int modifiers)Determines the necessary access level based on the current access level.protected static voidenableEnhancedAccess()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.Objectinvoke(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.Objectinvoke(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> TnewAccessor(java.lang.Class<T> iface, java.lang.Class<?> targetclass, java.lang.Object delegate)Creates a new accessor from an accessor class.static IExtractornewExtractor(java.lang.Class<IExtractor> extractorclass)protected static IMethodInvokernewInvoker(java.lang.Class<?> invokerclass)Instantiate a new method invoker from the invoker class.static IMethodInvokernewInvoker(java.lang.reflect.Method method)Creates a new invoker for a method.static IMethodInvokernewInvoker(java.lang.reflect.Method method, IByteCodeClassLoader cl)Creates a new invoker for a method.protected static voidprepareParameters(org.objectweb.asm.MethodVisitor mv, java.lang.Class<?>[] parameters)Readies the parameters for delegated method invocation.
 
- 
- 
- 
Field Detail- 
NAME_SUFFIX_COUNTERpublic static java.util.concurrent.atomic.AtomicLong NAME_SUFFIX_COUNTER Class name suffix counter.
 - 
DEFAULT_ACCESSpublic static boolean DEFAULT_ACCESS Flag if default / protected access via ASM is available. Cannot be final due to bootstrapping.
 - 
PRIVATE_ACCESSpublic static boolean PRIVATE_ACCESS Flag if private access via ASM is available. Cannot be final due to bootstrapping.
 - 
INVOKER_CLASSESprotected static volatile java.util.WeakHashMap<java.lang.reflect.Method,java.lang.Class<IMethodInvoker>> INVOKER_CLASSES Cached invoker classes, the invoker class does not prevent GC (tested).
 - 
ACCESSOR_CLASSESprotected static volatile java.util.WeakHashMap<java.lang.Class<?>,WeakKeyValueMap<java.lang.Class<?>,java.lang.Class<?>>> ACCESSOR_CLASSES Cached accessor classes.
 - 
EXTRACTOR_CLASSESprotected static volatile java.util.WeakHashMap<java.lang.Class<?>,WeakKeyValueMap<java.lang.Class<?>,java.lang.Class<?>>> EXTRACTOR_CLASSES Cached extractor classes.
 
- 
 - 
Method Detail- 
invokepublic static final 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. Method resolution is very basic and a performance penalty is incurred, do not use if you plan on making repeated calls or need good method resolution, use getInvoker() methods instead.- Parameters:
- obj- Object on which the method is to be called.
- methodname- Name of the methods.
- args- Invocation arguments.
- Returns:
- Return value of invocation.
 
 - 
invokepublic static final 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. Method resolution is very basic and a performance penalty is incurred, do not use if you plan on making repeated calls or need good method resolution, use getInvoker() methods instead.- Parameters:
- 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.
- Returns:
- Return value of invocation.
 
 - 
newInvokerpublic static final IMethodInvoker newInvoker(java.lang.reflect.Method method) Creates a new invoker for a method.- Parameters:
- method- The method.
- Returns:
- Instantiated invoker.
 
 - 
newInvokerpublic static final IMethodInvoker newInvoker(java.lang.reflect.Method method, IByteCodeClassLoader cl) Creates a new invoker for a method.- Parameters:
- method- The method.
- cl- ClassLoader to use.
- Returns:
- Instantiated invoker.
 
 - 
newInvokerprotected static final IMethodInvoker newInvoker(java.lang.Class<?> invokerclass) Instantiate a new method invoker from the invoker class.- Parameters:
- invokerclass- The invoker class.
- Returns:
- Instantiated invoker.
 
 - 
getInvokerClasspublic static final java.lang.Class<IMethodInvoker> getInvokerClass(java.lang.reflect.Method method) Gets an invoker class.- Parameters:
- clazz- The class used to map methods.
- methodidmap- The method ID map to store the mapping.
- Returns:
- The generated invoker.
 
 - 
createInvokerClassprotected static final java.lang.Class<IMethodInvoker> createInvokerClass(IByteCodeClassLoader cl, java.lang.reflect.Method method) Creates the invoker class.- Parameters:
- cl- ClassLoader to use for generated class.
- clazz- The class used to map methods.
- Returns:
- The generated invoker.
 
 - 
newAccessorpublic static final <T> T newAccessor(java.lang.Class<T> iface, java.lang.Class<?> targetclass, java.lang.Object delegate)Creates a new accessor from an accessor class.- Parameters:
- accessorclass- The accessor class.
- delegate- The delegation object / accessor target.
- Returns:
- Instantiated accessor.
 
 - 
getAccessorClasspublic static final <T> java.lang.Class<T> getAccessorClass(java.lang.Class<T> iface, java.lang.Class<?> targetclazz)Gets class for an interface-based accessor.- Parameters:
- iface- The accessor interface.
- targetclazz- The target class.
- Returns:
- The accessor class.
 
 - 
createAccessorClasspublic static final <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. Methods between the interface and the target class are matched.- Parameters:
- cl- The ClassLoader used to load the generated byte code.
- iface- The accessor interface.
- clazz- The target class of the accessor.
- Returns:
- The generated class.
 
 - 
newExtractorpublic static final IExtractor newExtractor(java.lang.Class<IExtractor> extractorclass) 
 - 
createExtractorClasspublic static final java.lang.Class<IExtractor> createExtractorClass(IByteCodeClassLoader cl, java.lang.Class<?> clazz, java.lang.String[] propnames, java.lang.reflect.Member[] accessormember) Creates extractor class.- Parameters:
- cl- ClassLoader to use for generated class.
- clazz- The class used to map methods.
- Returns:
- The generated invoker.
 
 - 
createClassprotected static final 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.- Parameters:
- classname- Simple name of the class.
- privileged- If the class should be "privileged" to allow access to non-publics.
- Returns:
- Preinitialized class writer.
 
 - 
prepareParametersprotected static final void prepareParameters(org.objectweb.asm.MethodVisitor mv, java.lang.Class<?>[] parameters)Readies the parameters for delegated method invocation. Converts primitives as appropriate.- Parameters:
- mv- The MethodVisitor being used.
- parameters- The parameters of the method.
 
 - 
determineAccessLevelprotected static final int determineAccessLevel(int currentlevel, int modifiers)Determines the necessary access level based on the current access level.- Parameters:
- currentlevel- The current level.
- modifiers- Modifiers of the target
- Returns:
- Needed access level.
 
 - 
createFallbackAccessorprotected static final <T> T createFallbackAccessor(java.lang.Class<T> iface, java.lang.Class<?> clazz, java.lang.Object obj)Implements an accessor based on a dynamic proxy.- Parameters:
- cl- ClassLoader to use.
- iface- The interface to implement.
- clazz- The target class.
- obj- The target class or null if all static.
- Returns:
- Accessor.
 
 - 
enableEnhancedAccessprotected static final void enableEnhancedAccess() Tries to enable enhanced direct access.
 
- 
 
-