@Override protected boolean isCandidateForProperty(Method method, Class<?> targetClass) { Class<?> clazz = method.getDeclaringClass(); return (clazz != Object.class && clazz != Class.class && !ClassLoader.class.isAssignableFrom(targetClass)); }
@Override public String toString() { return String.format("%s.%s() %s", method.getDeclaringClass().getName(), method.getName(), arguments); } }
@Override protected boolean isCandidateForInvocation(Method method, Class<?> targetClass) { if (Modifier.isStatic(method.getModifiers())) { return false; } Class<?> clazz = method.getDeclaringClass(); return (clazz != Object.class && clazz != Class.class && !ClassLoader.class.isAssignableFrom(targetClass)); }
static RuntimeException methodError(Method method, @Nullable Throwable cause, String message, Object... args) { message = String.format(message, args); return new IllegalArgumentException(message + "\n for method " + method.getDeclaringClass().getSimpleName() + "." + method.getName(), cause); }
@Nullable protected CacheDefaults getCacheDefaults(Method method, @Nullable Class<?> targetType) { CacheDefaults annotation = method.getDeclaringClass().getAnnotation(CacheDefaults.class); if (annotation != null) { return annotation; } return (targetType != null ? targetType.getAnnotation(CacheDefaults.class) : null); }
public static boolean isSetBeanFactory(Method candidateMethod) { return (candidateMethod.getName().equals("setBeanFactory") && candidateMethod.getParameterCount() == 1 && BeanFactory.class == candidateMethod.getParameterTypes()[0] && BeanFactoryAware.class.isAssignableFrom(candidateMethod.getDeclaringClass())); } }
public CglibMethodInvocation(Object proxy, @Nullable Object target, Method method, Object[] arguments, @Nullable Class<?> targetClass, List<Object> interceptorsAndDynamicMethodMatchers, MethodProxy methodProxy) { super(proxy, target, method, arguments, targetClass, interceptorsAndDynamicMethodMatchers); // Only use method proxy for public methods not derived from java.lang.Object this.methodProxy = (Modifier.isPublic(method.getModifiers()) && method.getDeclaringClass() != Object.class && !AopUtils.isEqualsMethod(method) && !AopUtils.isHashCodeMethod(method) && !AopUtils.isToStringMethod(method) ? methodProxy : null); }
@Nullable private SendTo getSendTo(Method specificMethod) { SendTo ann = AnnotatedElementUtils.findMergedAnnotation(specificMethod, SendTo.class); if (ann == null) { ann = AnnotatedElementUtils.findMergedAnnotation(specificMethod.getDeclaringClass(), SendTo.class); } return ann; }
@Override @Nullable public Collection<CacheOperation> parseCacheAnnotations(Method method) { DefaultCacheConfig defaultConfig = new DefaultCacheConfig(method.getDeclaringClass()); return parseCacheAnnotations(defaultConfig, method); }
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { Method method = this.method; Assert.state(method != null, "No method handle"); String classDesc = method.getDeclaringClass().getName().replace('.', '/'); generateCodeForArguments(mv, cf, method, this.children); mv.visitMethodInsn(INVOKESTATIC, classDesc, method.getName(), CodeFlow.createSignatureDescriptor(method), false); cf.pushDescriptor(this.exitTypeDescriptor); }
@Override public boolean isMatch(Method candidateMethod) { return (candidateMethod.getDeclaringClass() != Object.class && !BeanFactoryAwareMethodInterceptor.isSetBeanFactory(candidateMethod) && BeanAnnotationHelper.isBeanAnnotated(candidateMethod)); }
private Method getGetterFromSetter(Method setter) { String getterName = setter.getName().replaceFirst("set", "get"); try { return setter.getDeclaringClass().getMethod(getterName); } catch (NoSuchMethodException ex) { // must be write only return null; } }
/** * Verifies that {@code method} produces a {@link NullPointerException} or {@link * UnsupportedOperationException} when the parameter in position {@code paramIndex} is null. If * this parameter is marked nullable, this method does nothing. * * @param instance the instance to invoke {@code method} on, or null if {@code method} is static */ public void testMethodParameter( @Nullable final Object instance, final Method method, int paramIndex) { method.setAccessible(true); testParameter(instance, invokable(instance, method), paramIndex, method.getDeclaringClass()); }
@Override public Object invoke(MethodInvocation mi) throws Throwable { if (mi.getMethod().getDeclaringClass().equals(AddedGlobalInterface.class)) { return new Integer(-1); } return mi.proceed(); } }
@Override public Object invoke(Object proxy, Method method, @Nullable Object[] args) throws Throwable { // If the method is a method from Object then defer to normal invocation. if (method.getDeclaringClass() == Object.class) { return method.invoke(this, args); } if (platform.isDefaultMethod(method)) { return platform.invokeDefaultMethod(method, service, proxy, args); } return loadServiceMethod(method).invoke(args != null ? args : emptyArgs); } });
static void scan(Class<?> clazz) { for (Method m : clazz.getMethods()) { if (m.getDeclaringClass() == clazz) { if ((m.getModifiers() & Modifier.STATIC) == 0) { if ((m.getModifiers() & (Modifier.PUBLIC | Modifier.FINAL)) == Modifier.PUBLIC) { fail("Not final: " + m); } } } } }
private static void doTestMocking(RateLimiter mock) throws Exception { for (Method method : RateLimiter.class.getMethods()) { if (!isStatic(method.getModifiers()) && !NOT_WORKING_ON_MOCKS.contains(method.getName()) && !method.getDeclaringClass().equals(Object.class)) { method.invoke(mock, arbitraryParameters(method)); } } }
@Override protected void assertions(MethodInvocation invocation) { assertTrue(invocation.getThis() == this); assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(), ITestBean.class.isAssignableFrom(invocation.getMethod().getDeclaringClass())); } }
@Override protected void assertions(MethodInvocation invocation) { assertSame(this, invocation.getThis()); assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(), ITestBean.class.isAssignableFrom(invocation.getMethod().getDeclaringClass())); } }
@Override protected void assertions(MethodInvocation invocation) { assertEquals(this, invocation.getThis()); assertEquals("Invocation should be on ITestBean: " + invocation.getMethod(), ITestBean.class, invocation.getMethod().getDeclaringClass()); } };