Example usage for java.lang.reflect Method getDeclaringClass

List of usage examples for java.lang.reflect Method getDeclaringClass

Introduction

In this page you can find the example usage for java.lang.reflect Method getDeclaringClass.

Prototype

@Override
public Class<?> getDeclaringClass() 

Source Link

Document

Returns the Class object representing the class or interface that declares the method represented by this object.

Usage

From source file:com.newtranx.util.monitoring.MonitorAspect.java

private static Method getMethod(MethodSignature signature, ProceedingJoinPoint pjp) {
    Method method = signature.getMethod();
    if (method.getDeclaringClass().isInterface()) {
        try {//from   ww  w.  ja  v  a2  s.  c  o m
            method = pjp.getTarget().getClass().getDeclaredMethod(pjp.getSignature().getName(),
                    method.getParameterTypes());
        } catch (NoSuchMethodException | SecurityException e) {
            throw new RuntimeException(e);
        }
    }
    return method;
}

From source file:de.otto.jsonhome.generator.MethodHelper.java

private static Method methodFromSuperclass(final Method method) {
    final Class<?> superclass = method.getDeclaringClass().getSuperclass();
    if (superclass != null) {
        return ClassUtils.getMethodIfAvailable(superclass, method.getName(), method.getParameterTypes());
    }/* w  w  w  .  j av  a  2s .c om*/
    return null;
}

From source file:Main.java

/**
 * set method is accessible/*from  www  .  j av a2s .  co m*/
 * 
 * @param method {@link java.lang.reflect.Method}
 */
public static void makeAccessible(final Method method) {
    if (!Modifier.isPublic(method.getModifiers())
            || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
        method.setAccessible(true);
    }
}

From source file:com.galenframework.reports.GalenTestInfo.java

public static GalenTestInfo fromMethod(Method method) {
    String name = method.getDeclaringClass().getSimpleName() + "#" + method.getName();
    return GalenTestInfo.fromString(name);
}

From source file:com.m3.methodcache.interceptor.AbstractCacheResultInterceptor.java

/**
 * Returns class part only from Method object
 *
 * @param invokedMethod method/*  w  w w  .j a v a  2s .co m*/
 * @return class part only
 */
protected static String getClassPartOnly(Method invokedMethod) {
    return getClassNameWithoutS2AOP(invokedMethod.getDeclaringClass().getCanonicalName());
}

From source file:com.robertsmieja.test.utils.junit.Internal.java

static void doNotUseDefaultMethod(Class<?> aClass, String methodName, Class<?>... parameterTypes) {
    Method methodToCheck = MethodUtils.getAccessibleMethod(aClass, methodName, parameterTypes);
    Assertions.assertNotEquals(Object.class, methodToCheck.getDeclaringClass(),
            methodName + "() method not implemented");
}

From source file:com.ms.commons.test.common.OutputUtil.java

synchronized public static void enter(Method method) {
    inmethod = method;//  ww w  .  j a v  a  2s.  co m
    started = System.currentTimeMillis();
    cache.add("-+-- enter method " + method.getDeclaringClass().getName() + "#" + method.getName());
}

From source file:com.edmunds.autotest.ClassUtil.java

public static boolean isDeclaredUnderRootPackage(AutoTestConfig config, Method method) {
    return isClassUnderRootPackage(config, method.getDeclaringClass());
}

From source file:com.seleniumtests.util.StringUtility.java

public static String constructMethodSignature(final Method method, final Object[] parameters) {
    return method.getDeclaringClass().getCanonicalName() + "." + method.getName() + "("
            + constructParameterString(parameters) + ")";
}

From source file:com.github.mbenson.privileged.weaver.FilesystemWeaver.java

private static Set<Class<?>> getDeclaringClasses(Iterable<Method> methods) {
    final Set<Class<?>> declaringClasses = new HashSet<Class<?>>();
    for (final Method method : methods) {
        declaringClasses.add(method.getDeclaringClass());
    }/*from w  w w  .jav  a2s. c  om*/
    return declaringClasses;
}