private static void validateClassValues(AnnotationMirror annotationMirror) {
    // A class literal can appear in three places:
    // * for an element of type Class, for example @SomeAnnotation(Foo.class);
    // * for an element of type Class[], for example @SomeAnnotation({Foo.class, Bar.class});
    // * inside a nested annotation, for example @SomeAnnotation(@Nested(Foo.class)).
    // These three possibilities are the three branches of the if/else chain below.
    annotationMirror
        .getElementValues()
        .forEach(
            (method, value) -> {
              TypeMirror type = method.getReturnType();
              if (isJavaLangClass(type) && !(value.getValue() instanceof TypeMirror)) {
                throw new MissingTypeException(null);
              } else if (type.getKind().equals(TypeKind.ARRAY)
                  && isJavaLangClass(MoreTypes.asArray(type).getComponentType())
                  && value.getValue() instanceof List<?>) {
                @SuppressWarnings("unchecked") // a List can only be a List<AnnotationValue> here
                List<AnnotationValue> values = (List<AnnotationValue>) value.getValue();
                if (values.stream().anyMatch(av -> !(av.getValue() instanceof TypeMirror))) {
                  throw new MissingTypeException(null);
                }
              } else if (type.getKind().equals(TypeKind.DECLARED)
                  && MoreTypes.asElement(type).getKind().equals(ElementKind.ANNOTATION_TYPE)
                  && value.getValue() instanceof AnnotationMirror) {
                validateClassValues((AnnotationMirror) value.getValue());
              }
            });
  }
Throws an exception if this annotation contains a value for a Class element that is not
actually a type. The assumption is that the value is the string {@code "<error>"} which javac
presents when a Class value is an undefined type.
value/src/main/java/com/google/auto/value/processor/AnnotationOutput.java