Tabnine Logo
java.lang.reflect
Code IndexAdd Tabnine to your IDE (free)

How to use java.lang.reflect

Best Java code snippets using java.lang.reflect (Showing top 20 results out of 125,226)

origin: stackoverflow.com

 Field field = targetClass.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(object, value);
origin: stackoverflow.com

 Method method = targetClass.getDeclaredMethod(methodName, argClasses);
method.setAccessible(true);
return method.invoke(targetObject, argObjects);
origin: spring-projects/spring-framework

@Override
public Class<?> getPropertyType() {
  if (this.member instanceof Method) {
    return ((Method) this.member).getReturnType();
  }
  else {
    return ((Field) this.member).getType();
  }
}
origin: square/okhttp

boolean warnIfOpen(Object closeGuardInstance) {
 boolean reported = false;
 if (closeGuardInstance != null) {
  try {
   warnIfOpenMethod.invoke(closeGuardInstance);
   reported = true;
  } catch (Exception ignored) {
  }
 }
 return reported;
}
origin: apache/incubator-dubbo

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;
}
origin: spring-projects/spring-framework

/**
 * 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));
}
origin: spring-projects/spring-framework

@Override
public boolean isStatic() {
  return Modifier.isStatic(this.introspectedMethod.getModifiers());
}
origin: google/guava

/** 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;
}
origin: spring-projects/spring-framework

@Override
public boolean isAbstract() {
  return Modifier.isAbstract(this.introspectedMethod.getModifiers());
}
origin: spring-projects/spring-framework

@Override
public boolean isFinal() {
  return Modifier.isFinal(this.introspectedMethod.getModifiers());
}
origin: google/guava

/**
 * 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;
}
origin: spring-projects/spring-framework

  @Override
  public boolean matches(Method m) {
    return Modifier.isProtected(m.getModifiers());
  }
});
origin: square/retrofit

Builder(Retrofit retrofit, Method method) {
 this.retrofit = retrofit;
 this.method = method;
 this.methodAnnotations = method.getAnnotations();
 this.parameterTypes = method.getGenericParameterTypes();
 this.parameterAnnotationsArray = method.getParameterAnnotations();
}
origin: google/guava

 @Override
 boolean isVisible(int modifiers) {
  return !Modifier.isPrivate(modifiers);
 }
},
origin: google/guava

 @Override
 public final boolean isVarArgs() {
  return method.isVarArgs();
 }
}
origin: square/retrofit

/**
 * 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;
}
origin: square/okhttp

public static void addSuppressedIfPossible(Throwable e, Throwable suppressed) {
 if (addSuppressedExceptionMethod != null) {
  try {
   addSuppressedExceptionMethod.invoke(e, suppressed);
  } catch (InvocationTargetException | IllegalAccessException ignored) {
  }
 }
}
origin: apache/incubator-dubbo

public static boolean isPublicInstanceField(Field field) {
  return Modifier.isPublic(field.getModifiers())
      && !Modifier.isStatic(field.getModifiers())
      && !Modifier.isFinal(field.getModifiers())
      && !field.isSynthetic();
}
origin: square/okhttp

Object createAndOpen(String closer) {
 if (getMethod != null) {
  try {
   Object closeGuardInstance = getMethod.invoke(null);
   openMethod.invoke(closeGuardInstance, closer);
   return closeGuardInstance;
  } catch (Exception ignored) {
  }
 }
 return null;
}
origin: apache/incubator-dubbo

public static boolean isPublicInstanceField(Field field) {
  return Modifier.isPublic(field.getModifiers())
      && !Modifier.isStatic(field.getModifiers())
      && !Modifier.isFinal(field.getModifiers())
      && !field.isSynthetic();
}
java.lang.reflect

Most used classes

  • Method
    This class represents a method. Information about the method can be accessed, and the method can be
  • Field
    This class represents a field. Information about the field can be accessed, and the field's value ca
  • Constructor
    Constructor provides information about, and access to, a single constructor for a class.Constructor
  • Modifier
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • InvocationTargetException
    InvocationTargetException is a checked exception that wraps an exception thrown by an invoked method
  • ParameterizedType,
  • Proxy,
  • GenericArrayType,
  • TypeVariable,
  • Member,
  • AccessibleObject,
  • AnnotatedElement,
  • UndeclaredThrowableException,
  • WildcardType,
  • Parameter,
  • Type,
  • InvocationHandler,
  • Executable,
  • GenericDeclaration
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now