Class OptionalMethod

java.lang.Object
org.conscrypt.metrics.OptionalMethod

@Internal public final class OptionalMethod extends Object
Helper class to handle reflexive loading and invocation of methods which may be absent.
  • Field Details

    • cachedMethod

      private final Method cachedMethod
  • Constructor Details

    • OptionalMethod

      public OptionalMethod(Class<?> clazz, String methodName, Class<?>... methodParams)
      Instantiates a new OptionalMethod.

      Does not throw any exceptions if the class or method can't be loaded, or if any parameter classes are null and instead behaves as a no-op, always returning null.

      Parameters:
      clazz - the Class to search for methods on
      methodName - the name of the Method on clazz
      methodParams - list of Classes of the Method's parameters
      Throws:
      NullPointerException - if the method name is null
  • Method Details

    • initializeMethod

      private static Method initializeMethod(Class<?> clazz, String methodName, Class<?>... methodParams)
    • invokeStatic

      public Object invokeStatic(Object... args)
    • invoke

      public Object invoke(Object target, Object... args)
    • checkNotNull

      private static <T> T checkNotNull(T reference)