@Override public T call() throws Exception { // use the Thread's context ClassLoader to resolve the Class. ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Class<?> clazz = classLoader.loadClass(className); // resolve the static method to call Method method = ReflectionHelper.getCompatibleMethod(clazz, methodName, args); // was the method found? if (method == null) { throw new NoSuchMethodException("The specified method [" + className + "." + methodName + "] for the arguments " + Arrays.toString(args) + " could not be located"); } else { // ensure that the method is static if (Modifier.isStatic(method.getModifiers())) { return args.length > 0 ? (T) method.invoke(null, args) : (T) method.invoke(null); } else { throw new IllegalArgumentException("The specified method [" + className + "." + methodName + "] is not static"); } } }
/** * Create an Object via reflection (using the specified {@link ClassLoader}). * * @param className The name of the class to instantiate. * @param classLoader The {@link ClassLoader} to use to load the class. * @param constructorParameterList The set of parameters to pass to the constructor * * @return A new instance of the class specified by the className * * @throws ClassNotFoundException if the class is not found * @throws NoSuchMethodException if there is no such constructor * @throws InstantiationException if it failed to instantiate * @throws IllegalAccessException if security doesn't allow the call * @throws InvocationTargetException if the constructor failed */ public static Object createObject(String className, ClassLoader classLoader, Object... constructorParameterList) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<?> clazz = Class.forName(className, true, classLoader); Class<?>[] parameterTypes = getClassArrayFromObjectArray(constructorParameterList); Constructor<?> con = ReflectionHelper.getCompatibleConstructor(clazz, parameterTypes); return con.newInstance(constructorParameterList); }
annotation = getAnnotation(onInterface, desiredAnnotationClass); return getAnnotation(onClass.getSuperclass(), desiredAnnotationClass);
Constructor<? extends Application> constructor = ReflectionHelper.getCompatibleConstructor(applicationClass, platform.getClass(), LocalApplicationProcess.class,
parametersMatch = isAssignablePrimitive(argumentType, formalParameterType);
Constructor<? extends Application> constructor = ReflectionHelper.getCompatibleConstructor(applicationClass, platform.getClass(), LocalApplicationProcess.class,
parametersMatch = isAssignablePrimitive(argumentType, formalParameterType);
@Override public T call() throws Exception { // use the Thread's context ClassLoader to resolve the Class. ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Class<?> clazz = classLoader.loadClass(className); // resolve the static method to call Method method = ReflectionHelper.getCompatibleMethod(clazz, methodName, args); // was the method found? if (method == null) { throw new NoSuchMethodException("The specified method [" + className + "." + methodName + "] for the arguments " + Arrays.toString(args) + " could not be located"); } else { // ensure that the method is static if (Modifier.isStatic(method.getModifiers())) { return args.length > 0 ? (T) method.invoke(null, args) : (T) method.invoke(null); } else { throw new IllegalArgumentException("The specified method [" + className + "." + methodName + "] is not static"); } } }
Constructor<? extends A> constructor = ReflectionHelper.getCompatibleConstructor(applicationClass, platform.getClass(), localJavaProcess.getClass(),
/** * Create an Object via reflection (using the specified {@link ClassLoader}). * * @param className The name of the class to instantiate. * @param classLoader The {@link ClassLoader} to use to load the class. * @param constructorParameterList The set of parameters to pass to the constructor * * @return A new instance of the class specified by the className * * @throws ClassNotFoundException if the class is not found * @throws NoSuchMethodException if there is no such constructor * @throws InstantiationException if it failed to instantiate * @throws IllegalAccessException if security doesn't allow the call * @throws InvocationTargetException if the constructor failed */ public static Object createObject(String className, ClassLoader classLoader, Object... constructorParameterList) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<?> clazz = Class.forName(className, true, classLoader); Class<?>[] parameterTypes = getClassArrayFromObjectArray(constructorParameterList); Constructor<?> con = ReflectionHelper.getCompatibleConstructor(clazz, parameterTypes); return con.newInstance(constructorParameterList); }
parametersMatch = isAssignablePrimitive(argumentType, formalParameterType); parametersMatch = isAssignablePrimitive(formalParameterType, argumentType);
annotation = getAnnotation(onInterface, desiredAnnotationClass); return getAnnotation(onClass.getSuperclass(), desiredAnnotationClass);
Method method = ReflectionHelper.getCompatibleMethod(instance.getClass(), methodName, arguments);
Constructor<? extends A> constructor = ReflectionHelper.getCompatibleConstructor(applicationClass, platform.getClass(), localJavaProcess.getClass(),
parametersMatch = isAssignablePrimitive(argumentType, formalParameterType); parametersMatch = isAssignablePrimitive(formalParameterType, argumentType);
Method method = ReflectionHelper.getCompatibleMethod(instance.getClass(), methodName, arguments);
Constructor<? extends A> constructor = ReflectionHelper.getCompatibleConstructor(applicationClass, platform.getClass(), process.getClass(),
Method method = ReflectionHelper.getCompatibleMethod(NamedCache.class, methodName, arguments);
Constructor<? extends A> constructor = ReflectionHelper.getCompatibleConstructor(applicationClass, platform.getClass(), process.getClass(),
Method method = ReflectionHelper.getCompatibleMethod(NamedCache.class, methodName, arguments);