@Override public void finalizeReference() { setStrongMetaClass(null); cachedClassRef.clear(); artifactClassLoader.clear(); }
public static void onAllClassInfo(ClassInfoAction action) { for (ClassInfo classInfo : getAllGlobalClassInfo()) { action.onClassInfo(classInfo); } }
static boolean noCoerce(ParameterTypes metaMethod, Object[] args) { final CachedClass[] paramClasses = metaMethod.getParameterTypes(); if (paramClasses.length != args.length) return false; for (int i = 0; i < paramClasses.length; i++) { CachedClass paramClass = paramClasses[i]; if (args[i] != null && !paramClass.isDirectlyAssignable(args[i])) return true; } return false; }
private synchronized void getNativeParameterTypes0() { if (nativeParamTypes != null) return; Class[] npt; if (parameterTypes != null) { npt = new Class[parameterTypes.length]; for (int i = 0; i != parameterTypes.length; ++i) { npt[i] = parameterTypes[i].getTheClass(); } } else npt = getPT(); nativeParamTypes = npt; }
public boolean isAssignableFrom(Class argument) { return argument == null || ReflectionCache.isAssignableFrom(getTheClass(), argument); }
public ClosureMetaMethod(String name, Class declaringClass, Closure c, CachedMethod doCall) { super (doCall.getNativeParameterTypes()); this.name = name; callable = c; this.doCall = doCall; this.declaringClass = ReflectionCache.getCachedClass(declaringClass); }
public boolean isValidExactMethod(Class[] args) { // lets check the parameter types match getParametersTypes0(); int size = args.length; if (size != parameterTypes.length) return false; for (int i = 0; i < size; i++) { if (args[i] != null && !parameterTypes[i].isAssignableFrom(args[i])) { return false; } } return true; }
@Override public Class getReturnType() { return cc.getCachedClass().getTheClass(); } @Override
public final Object[] coerceArgumentsToClasses(Object[] argumentArray) { // Uncomment if at some point this method can be called before parameterTypes initialized // getParameterTypes(); argumentArray = correctArguments(argumentArray); final CachedClass[] pt = parameterTypes; final int len = argumentArray.length; for (int i = 0; i < len; i++) { final Object argument = argumentArray[i]; if (argument != null) { argumentArray[i] = pt[i].coerceArgument(argument); } } return argumentArray; }
/** * Get the called that is matchLevel stack frames before the call, * ignoring MOP frames. * * @param matchLevel how may call stacks down to look. * If it is less than 1 it is treated as though it was 1. * @return The Class of the matched caller, or null if there aren't * enough stackframes to satisfy matchLevel */ public static Class getCallingClass(int matchLevel) { return getCallingClass(matchLevel, Collections.EMPTY_SET); }
private static boolean isValidExactMethod(Class[] arguments, CachedClass[] pt) { // lets check the parameter types match int size = pt.length; for (int i = 0; i < size; i++) { if (!pt[i].isAssignableFrom(arguments[i])) { return false; } } return true; }
public Class[] getNativeParameterTypes() { if (nativeParamTypes == null) { getNativeParameterTypes0(); } return nativeParamTypes; }
public CachedClass[] getParameterTypes() { if (parameterTypes == null) { getParametersTypes0(); } return parameterTypes; }
private MetaMethod[] getNewMetaMethods(CachedClass c) { if (theCachedClass != c) return c.getNewMetaMethods(); return myNewMetaMethods; }
/** * Extend object with category methods. * All methods for given class and all super classes will be added to the object. * * @param self any Class * @param categoryClasses a category classes to use * @since 1.6.0 */ public static void mixin(MetaClass self, List<Class> categoryClasses) { MixinInMetaClass.mixinClassesToMetaClass(self, categoryClasses); }
/** * Increments version of the contained Class */ public void incVersion() { theCachedClass.classInfo.incVersion(); }
public MetaClass getMetaClassForClass() { // safe value here to avoid multiple reads with possibly // differing values due to concurrency MetaClass strongMc = strongMetaClass; if (strongMc!=null) return strongMc; MetaClass weakMc = getWeakMetaClass(); if (isValidWeakMetaClass(weakMc)) { return weakMc; } return null; }
@Override public T get(Class<?> type) { // the value isn't use in the getOrPut call - see the EntryWithValue constructor above T value = ((EntryWithValue)map.getOrPut(type, null)).getValue(); //all entries are guaranteed to be EntryWithValue. Value can only be null if computeValue returns null return value; }
public Class instanceCaller() { return ReflectionUtils.getCallingClass(); } }