Package com.googlecode.aviator.utils
Class Reflector
java.lang.Object
com.googlecode.aviator.utils.Reflector
Some code is copied from
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
Class's instance method cache key(package private) static class
static enum
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ConcurrentHashMap
<Class<?>, Reference<Map<String, Reflector.PropertyFoundResult>>> static method cachingstatic ConcurrentHashMap
<Class<?>, Reference<Map<String, Reflector.PropertyFoundResult>>> static and instance fields property cachingprivate static final ReferenceQueue
<Map<String, Reflector.PropertyFoundResult>> static ConcurrentHashMap
<Class<?>, Reference<Map<String, Reflector.PropertyFoundResult>>> instance fields setter caching.private static final ReferenceQueue
<Map<String, Reflector.PropertyFoundResult>> private static final ReferenceQueue
<Map<String, Reflector.PropertyFoundResult>> (package private) static ConcurrentHashMap
<Reflector.MethodKey, Reference<List<Method>>> (package private) static final ReferenceQueue
<List<Method>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Object
static Object[]
static StringBuilder
capitalize
(StringBuilder sb, String s) (package private) static <K,
V> void clearCache
(ReferenceQueue<V> rq, ConcurrentHashMap<K, Reference<V>> cache) static Object
fastGetProperty
(Object obj, String name, Reflector.PropertyType type) static Object
fastGetProperty
(String name, String[] names, Map<String, Object> env, Reflector.Target target, boolean tryResolveStaticMethod, int offset, int len) findMethodsFromClass
(Class<?> clazz, boolean isStatic) private static String
genGetterName
(String prefix, String name) private static Throwable
getClassInstanceMethods
(Class<?> c, String methodName) private static Map
<String, Reflector.PropertyFoundResult> getClassPropertyResults
(ConcurrentHashMap<Class<?>, Reference<Map<String, Reflector.PropertyFoundResult>>> cache, ReferenceQueue<Map<String, Reflector.PropertyFoundResult>> rq, Class<?> clazz) getInstanceMethods
(Class<?> clazz, String methodName) static Object
getProperty
(Object target, String name) getStaticMethods
(Class<?> c, String methodName) static Object
invokeInstanceMethod
(Class<?> c, String methodName, Object target, List<Method> methods, Object[] args) (package private) static Object
invokeMatchingMethod
(String methodName, List methods, Object target, Object[] args) static Object
static boolean
isCongruent
(Class<?>[] params, Object[] args) private static String
noMethodReport
(String methodName, Object target, Object[] args) static boolean
paramArgTypeMatch
(Class<?> paramType, Class<?> argType) private static void
putDummyHandle
(String name, Map<String, Reflector.PropertyFoundResult> handles) private static Reflector.PropertyFoundResult
retrieveGetterHandle
(Map<String, Reflector.PropertyFoundResult> results, Class<?> clazz, String name) private static Reflector.PropertyFoundResult
retrieveSetterHandle
(Map<String, Reflector.PropertyFoundResult> results, Class<?> clazz, String name) private static Reflector.PropertyFoundResult
retrieveStaticFieldHandle
(Map<String, Reflector.PropertyFoundResult> results, Class<?> clazz, String name) private static Reflector.PropertyFoundResult
retrieveStaticFunction
(Map<String, Reflector.PropertyFoundResult> results, Class<?> clazz, String name) static void
static RuntimeException
Throw even checked exceptions without being required to declare them or catch them.private static <T extends Throwable>
voidstatic boolean
static Object
-
Field Details
-
cachedProperties
public static ConcurrentHashMap<Class<?>,Reference<Map<String, cachedPropertiesReflector.PropertyFoundResult>>> static and instance fields property caching -
cachedSettters
public static ConcurrentHashMap<Class<?>,Reference<Map<String, cachedSetttersReflector.PropertyFoundResult>>> instance fields setter caching. -
cachedSetterRq
-
cachePropertyRq
-
cachedMethods
public static ConcurrentHashMap<Class<?>,Reference<Map<String, cachedMethodsReflector.PropertyFoundResult>>> static method caching -
cacheMethodRq
-
instanceMethodsCache
-
instanceMethodsRq
-
longClasses
-
doubleClasses
-
-
Constructor Details
-
Reflector
public Reflector()
-
-
Method Details
-
sneakyThrow
Throw even checked exceptions without being required to declare them or catch them. Suggested idiom:throw sneakyThrow( some exception );
-
sneakyThrow0
- Throws:
T
-
noMethodReport
-
subsumes
-
getCauseOrElse
-
invokeMatchingMethod
-
capitalize
-
genGetterName
-
fastGetProperty
-
throwNoSuchPropertyException
-
retrieveStaticFieldHandle
private static Reflector.PropertyFoundResult retrieveStaticFieldHandle(Map<String, Reflector.PropertyFoundResult> results, Class<?> clazz, String name) throws IllegalAccessException, NoSuchFieldException -
retrieveStaticFunction
private static Reflector.PropertyFoundResult retrieveStaticFunction(Map<String, Reflector.PropertyFoundResult> results, Class<?> clazz, String name) throws IllegalAccessException, NoSuchMethodException -
retrieveGetterHandle
private static Reflector.PropertyFoundResult retrieveGetterHandle(Map<String, Reflector.PropertyFoundResult> results, Class<?> clazz, String name) throws IllegalAccessException- Throws:
IllegalAccessException
-
retrieveSetterHandle
private static Reflector.PropertyFoundResult retrieveSetterHandle(Map<String, Reflector.PropertyFoundResult> results, Class<?> clazz, String name) throws IllegalAccessException- Throws:
IllegalAccessException
-
putDummyHandle
-
getClassPropertyResults
private static Map<String,Reflector.PropertyFoundResult> getClassPropertyResults(ConcurrentHashMap<Class<?>, Reference<Map<String, Reflector.PropertyFoundResult>>> cache, ReferenceQueue<Map<String, Reflector.PropertyFoundResult>> rq, Class<?> clazz) -
getStaticMethods
-
clearCache
-
getInstanceMethods
-
getClassInstanceMethods
-
invokeStaticMethod
-
invokeInstanceMethod
-
boxArg
-
boxArgs
-
asSet
-
paramArgTypeMatch
-
isCongruent
-
getProperty
-
setProperty
-
fastGetProperty
-
findMethodsFromClass
-