private static Class loadAnnotation()

in TransformCore/src/main/java/com/facebook/ads/injkit/sdkdebugger/SdkDebuggerInjector.java [46:86]


  private static Class<? extends Annotation> loadAnnotation(ClassLoader classLoader, String name)
      throws InvalidAnnotationProcessorConfigurationException {
    try {
      Class<?> cls = classLoader.loadClass(name);
      if (!Annotation.class.isAssignableFrom(cls)) {
        throw new InvalidAnnotationProcessorConfigurationException(
            String.format(
                Locale.US,
                "'%s' is not a subclass of '%s'",
                cls.getName(),
                Annotation.class.getName()));
      }

      @SuppressWarnings("unchecked")
      Class<? extends Annotation> clsAnnotation = (Class<? extends Annotation>) cls;

      if (!checkIfMethodExists(METHOD_DESCRIPTION_PARAM, cls)) {
        throw new InvalidAnnotationFormatException(
            String.format(
                Locale.US,
                "Annotation '%s' must declare a method %s",
                name,
                METHOD_DESCRIPTION_PARAM));
      }

      Retention retention = clsAnnotation.getAnnotation(Retention.class);
      if (retention == null || retention.value() == RetentionPolicy.RUNTIME) {
        throw new InvalidAnnotationProcessorConfigurationException(
            String.format(
                Locale.US,
                "Annotation '%s' must have @Retention with RetentionPolicy.CLASS "
                    + "or RetentionPolicy.RUNTIME",
                name));
      }

      return clsAnnotation;
    } catch (ClassNotFoundException e) {
      throw new InvalidAnnotationProcessorConfigurationException(
          String.format(Locale.US, "Failed to load class '%s'", name), e);
    }
  }