Exemplo n.º 1
0
 protected Object getField(Object o, Class<?> clazz, String name) {
   try {
     Field f = clazz.getDeclaredField(name);
     boolean prev = f.isAccessible();
     f.setAccessible(true);
     try {
       return f.get(o);
     } finally {
       f.setAccessible(prev);
     }
   } catch (ReflectiveOperationException e) {
     return e;
   } catch (SecurityException e) {
     return e;
   }
 }
Exemplo n.º 2
0
 protected Object callMethod(Object o, Class<?> clazz, String name) {
   try {
     Method m = clazz.getDeclaredMethod(name);
     boolean prev = m.isAccessible();
     m.setAccessible(true);
     try {
       return m.invoke(o);
     } finally {
       m.setAccessible(prev);
     }
   } catch (ReflectiveOperationException e) {
     return e;
   } catch (SecurityException e) {
     return e;
   }
 }
Exemplo n.º 3
0
 protected String info(Class<?> clazz, Object internal, Object external) {
   return String.format("%s,%s,%s", clazz.getSimpleName(), internal, external);
 }