Field field = targetClass.getDeclaredField(fieldName); field.setAccessible(true); field.set(object, value);
Method method = targetClass.getDeclaredMethod(methodName, argClasses); method.setAccessible(true); return method.invoke(targetObject, argObjects);
@Override public Class<?> getPropertyType() { if (this.member instanceof Method) { return ((Method) this.member).getReturnType(); } else { return ((Field) this.member).getType(); } }
boolean warnIfOpen(Object closeGuardInstance) { boolean reported = false; if (closeGuardInstance != null) { try { warnIfOpenMethod.invoke(closeGuardInstance); reported = true; } catch (Exception ignored) { } } return reported; }
private Object resolve(Object obj) throws Exception { // if there's a readResolve method, call it try { if (_readResolve != null) return _readResolve.invoke(obj, new Object[0]); } catch (InvocationTargetException e) { if (e.getTargetException() != null) throw e; } return obj; }
/** * Determine whether the given field is a "public static final" constant. * @param field the field to check */ public static boolean isPublicStaticFinal(Field field) { int modifiers = field.getModifiers(); return (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers)); }
@Override public boolean isStatic() { return Modifier.isStatic(this.introspectedMethod.getModifiers()); }
/** Determines whether the given method takes a Guard as its first parameter. */ private static boolean isGuarded(Method method) { Class<?>[] parameterTypes = method.getParameterTypes(); return parameterTypes.length >= 1 && parameterTypes[0] == Monitor.Guard.class; }
@Override public boolean isAbstract() { return Modifier.isAbstract(this.introspectedMethod.getModifiers()); }
@Override public boolean isFinal() { return Modifier.isFinal(this.introspectedMethod.getModifiers()); }
/** * Checks whether {@code method} is thread-safe, as indicated by the presence of the {@link * AllowConcurrentEvents} annotation. */ private static boolean isDeclaredThreadSafe(Method method) { return method.getAnnotation(AllowConcurrentEvents.class) != null; }
@Override public boolean matches(Method m) { return Modifier.isProtected(m.getModifiers()); } });
Builder(Retrofit retrofit, Method method) { this.retrofit = retrofit; this.method = method; this.methodAnnotations = method.getAnnotations(); this.parameterTypes = method.getGenericParameterTypes(); this.parameterAnnotationsArray = method.getParameterAnnotations(); }
@Override boolean isVisible(int modifiers) { return !Modifier.isPrivate(modifiers); } },
@Override public final boolean isVarArgs() { return method.isVarArgs(); } }
/** * Returns the declaring class of {@code typeVariable}, or {@code null} if it was not declared by * a class. */ private static Class<?> declaringClassOf(TypeVariable<?> typeVariable) { GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration(); return genericDeclaration instanceof Class ? (Class<?>) genericDeclaration : null; }
public static void addSuppressedIfPossible(Throwable e, Throwable suppressed) { if (addSuppressedExceptionMethod != null) { try { addSuppressedExceptionMethod.invoke(e, suppressed); } catch (InvocationTargetException | IllegalAccessException ignored) { } } }
public static boolean isPublicInstanceField(Field field) { return Modifier.isPublic(field.getModifiers()) && !Modifier.isStatic(field.getModifiers()) && !Modifier.isFinal(field.getModifiers()) && !field.isSynthetic(); }
public static boolean isPublicInstanceField(Field field) { return Modifier.isPublic(field.getModifiers()) && !Modifier.isStatic(field.getModifiers()) && !Modifier.isFinal(field.getModifiers()) && !field.isSynthetic(); }