protected void visitAnnotations(AnnotatedNode node, int target) {
    if (node.getAnnotations().isEmpty()) {
      return;
    }
    this.currentClass.setAnnotated(true);
    if (!isAnnotationCompatible()) {
      addError("Annotations are not supported in the current runtime. " + JVM_ERROR_MESSAGE, node);
      return;
    }
    for (AnnotationNode unvisited : node.getAnnotations()) {
      AnnotationNode visited = visitAnnotation(unvisited);
      boolean isTargetAnnotation =
          visited.getClassNode().isResolved()
              && visited.getClassNode().getName().equals("java.lang.annotation.Target");

      // Check if the annotation target is correct, unless it's the target annotating an annotation
      // definition
      // defining on which target elements the annotation applies
      if (!isTargetAnnotation && !visited.isTargetAllowed(target)) {
        addError(
            "Annotation @"
                + visited.getClassNode().getName()
                + " is not allowed on element "
                + AnnotationNode.targetToName(target),
            visited);
      }
      visitDeprecation(node, visited);
    }
  }