List of usage examples for java.lang.reflect Field getDeclaringClass
@Override
public Class<?> getDeclaringClass()
From source file:Spy.java
public static void main(String... args) throws Exception { Class<?> c = Class.forName("Spy"); Field[] flds = c.getDeclaredFields(); for (Field f : flds) { System.out.println(f.getDeclaringClass()); }/*from ww w . j av a2s .c om*/ }
From source file:Main.java
protected static void makeAccessible(Field field) { if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) { field.setAccessible(true);/*from w w w. j a v a 2 s . co m*/ } }
From source file:Main.java
protected static void makeAccessible(final Field field) { if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) { field.setAccessible(true);//from www. ja v a2s. c om } }
From source file:ReflectionUtils.java
/** * Make the given field accessible, explicitly setting it accessible if necessary. * The <code>setAccessible(true)</code> method is only called when actually necessary, * to avoid unnecessary conflicts with a JVM SecurityManager (if active). * @param field the field to make accessible * @see java.lang.reflect.Field#setAccessible *///from w ww . ja v a 2 s . com public static void makeAccessible(Field field) { if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) { field.setAccessible(true); } }
From source file:Main.java
public static void classInspector(Object object) { Class cls = object.getClass(); System.out.println(cls.toString()); Field[] fieldlist = cls.getDeclaredFields(); for (int i = 0; i < fieldlist.length; i++) { Field fld = fieldlist[i]; System.out.println("name = " + fld.getName()); System.out.println("decl class = " + fld.getDeclaringClass()); System.out.println("type = " + fld.getType()); System.out.println("-----"); }/* www. jav a 2 s . co m*/ }
From source file:org.ireland.jnetty.config.ConfigException.java
public static String loc(Field field) { return field.getDeclaringClass().getName() + "." + field.getName() + ": "; }
From source file:Main.java
/** * set attribute is accessible/* w w w . ja v a2 s . com*/ * * @param field {@link java.lang.reflect.Field} */ public static void makeAccessible(final Field field) { if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) { field.setAccessible(true); } }
From source file:org.grouplens.grapht.util.FieldProxy.java
/** * Construct a proxy for a field./*from w w w . j a va 2 s.co m*/ * @param field The field to proxy. * @return The field proxy representing {@code field}. */ public static FieldProxy of(Field field) { FieldProxy proxy = new FieldProxy(ClassProxy.of(field.getDeclaringClass()), field.getName(), ClassProxy.of(field.getType())); proxy.field = field; return proxy; }
From source file:org.ngrinder.common.util.ReflectionUtil.java
private static void makeAccessible(final Field field) { if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) { field.setAccessible(true);/*from w w w . ja va 2 s.c o m*/ } }
From source file:com.edmunds.autotest.ClassUtil.java
public static boolean isDeclaredUnderRootPackage(AutoTestConfig config, Field field) { return isClassUnderRootPackage(config, field.getDeclaringClass()); }