private static Class loadAnnotation()

in TransformCore/src/main/java/com/facebook/ads/injkit/crashshield/CrashShieldInjector.java [87:118]


  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;

      Retention retention = clsAnnotation.getAnnotation(Retention.class);
      if (retention == null || retention.value() == RetentionPolicy.SOURCE) {
        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);
    }
  }