List of usage examples for java.lang.reflect Constructor getDeclaringClass
@Override
public Class<T> getDeclaringClass()
From source file:Main.java
public static void print_method_or_constructor(Member member) { Constructor c = (Constructor) member; Class[] parameters = c.getParameterTypes(); Class[] exceptions = c.getExceptionTypes(); System.out.println(c.getDeclaringClass()); for (int i = 0; i < parameters.length; i++) { System.out.println(parameters[i]); }// w ww. j av a2 s . co m for (int i = 0; i < exceptions.length; i++) { System.out.println(exceptions[i]); } }
From source file:org.codehaus.groovy.grails.plugins.springsecurity.acl.ProxyUtils.java
/** * Finds the constructor in the unproxied superclass if proxied. * @param constructor the constructor/*w w w .ja v a 2s . c o m*/ * @return the constructor in the unproxied class */ public static Constructor<?> unproxy(final Constructor<?> constructor) { Class<?> clazz = constructor.getDeclaringClass(); if (!AopUtils.isCglibProxyClass(clazz)) { return constructor; } Class<?> searchType = unproxy(clazz); while (searchType != null) { for (Constructor<?> c : searchType.getConstructors()) { if (constructor.getName().equals(c.getName()) && (constructor.getParameterTypes() == null || Arrays.equals(constructor.getParameterTypes(), c.getParameterTypes()))) { return c; } } searchType = searchType.getSuperclass(); } return null; }
From source file:ReflectUtils.java
/** * Convert the constructor to a Java Code String * (arguments are replaced by the simple types) * @param c Constructor//from w w w. j av a 2 s.c o m * @return */ public static String getJavaCallString(Constructor c) { StringBuilder call = new StringBuilder(); call.append(c.getDeclaringClass().getSimpleName()); addParamsString(call, c.getParameterTypes()); return call.toString(); }
From source file:grails.plugin.springsecurity.acl.util.ProxyUtils.java
/** * Finds the constructor in the unproxied superclass if proxied. * @param constructor the constructor/*from ww w .j a v a 2 s .co m*/ * @return the constructor in the unproxied class */ public static Constructor<?> unproxy(final Constructor<?> constructor) { Class<?> clazz = constructor.getDeclaringClass(); if (!isProxy(clazz)) { return constructor; } Class<?> searchType = unproxy(clazz); while (searchType != null) { for (Constructor<?> c : searchType.getConstructors()) { if (constructor.getName().equals(c.getName()) && (constructor.getParameterTypes() == null || Arrays.equals(constructor.getParameterTypes(), c.getParameterTypes()))) { return c; } } searchType = searchType.getSuperclass(); } return null; }
From source file:Main.java
/** * set constructor is accessible//w ww .j ava2 s . c o m * @param constructor {@link java.lang.reflect.Constructor} * @param <T> t */ public static <T> void makeAccessible(final Constructor<T> constructor) { if (!Modifier.isPublic(constructor.getModifiers()) || !Modifier.isPublic(constructor.getDeclaringClass().getModifiers())) { constructor.setAccessible(true); } }
From source file:ShowClass.java
public static void printMethodOrConstructor(Member member) { Class returntype = null, parameters[], exceptions[]; if (member instanceof Method) { Method m = (Method) member; returntype = m.getReturnType();/*from ww w . java2 s . c om*/ parameters = m.getParameterTypes(); exceptions = m.getExceptionTypes(); System.out.print( " " + modifiers(member.getModifiers()) + typeName(returntype) + " " + member.getName() + "("); } else { Constructor c = (Constructor) member; parameters = c.getParameterTypes(); exceptions = c.getExceptionTypes(); System.out.print(" " + modifiers(member.getModifiers()) + typeName(c.getDeclaringClass()) + "("); } for (int i = 0; i < parameters.length; i++) { if (i > 0) System.out.print(", "); System.out.print(typeName(parameters[i])); } System.out.print(")"); if (exceptions.length > 0) System.out.print(" throws "); for (int i = 0; i < exceptions.length; i++) { if (i > 0) System.out.print(", "); System.out.print(typeName(exceptions[i])); } System.out.println(";"); }
From source file:Main.java
public static void print_method_or_constructor(Member member) { Class returntype = null, parameters[], exceptions[]; if (member instanceof Method) { Method m = (Method) member; returntype = m.getReturnType();/* w w w . j a va 2 s . c o m*/ parameters = m.getParameterTypes(); exceptions = m.getExceptionTypes(); System.out.print( " " + modifiers(member.getModifiers()) + typename(returntype) + " " + member.getName() + "("); } else { Constructor c = (Constructor) member; parameters = c.getParameterTypes(); exceptions = c.getExceptionTypes(); System.out.print(" " + modifiers(member.getModifiers()) + typename(c.getDeclaringClass()) + "("); } for (int i = 0; i < parameters.length; i++) { if (i > 0) System.out.print(", "); System.out.print(typename(parameters[i])); } System.out.print(")"); if (exceptions.length > 0) System.out.print(" throws "); for (int i = 0; i < exceptions.length; i++) { if (i > 0) System.out.print(", "); System.out.print(typename(exceptions[i])); } System.out.println(";"); }
From source file:com.dianping.squirrel.client.util.ClassUtils.java
public static <T> Constructor<T> getDeclaredConstructor(Constructor<T> ctor) { if (ctor == null) { return (null); }/*from w w w. ja v a 2 s.c o m*/ Class<T> clazz = ctor.getDeclaringClass(); if (Modifier.isPublic(clazz.getModifiers())) { return (ctor); } return null; }
From source file:edu.umich.flowfence.common.QMDescriptor.java
public static QMDescriptor forConstructor(Context context, Constructor<?> ctor) { return forConstructor(context, ctor.getDeclaringClass(), ctor.getParameterTypes()); }
From source file:edu.umich.oasis.common.SodaDescriptor.java
public static SodaDescriptor forConstructor(Context context, Constructor<?> ctor) { return forConstructor(context, ctor.getDeclaringClass(), ctor.getParameterTypes()); }