private void addRepeatedExtensionAnnotations(AnnotatedNode annotatedNode) {
    ListExpression repeatedExtensionAnnotations = annotatedNode
      // get all repeatable extension annotations flattened
      .getAnnotations()
      .stream()
      .flatMap(this::flattenRepeatableExtensionAnnotationContainer)
      .filter(this::isRepeatableExtensionAnnotation)
      // find the annotations that occur multiple times
      .collect(groupingBy(AnnotationNode::getClassNode))
      .entrySet()
      .stream()
      .filter(entry -> entry.getValue().size() > 1)
      // put them to a ListExpression
      .map(Map.Entry::getKey)
      .map(ClassExpression::new)
      .collect(collectingAndThen(Collectors.<Expression>toList(), ListExpression::new));

    // if any were found, put them to a RepeatedExtensionAnnotations annotation as runtime hint
    if (repeatedExtensionAnnotations.getExpressions().size() != 0) {
      AnnotationNode ann = new AnnotationNode(nodeCache.RepeatedExtensionAnnotations);
      ann.setMember(RepeatedExtensionAnnotations.VALUE, repeatedExtensionAnnotations);
      annotatedNode.addAnnotation(ann);
    }
  }
Puts all spec information required at runtime into annotations
attached to class members.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/compiler/SpecAnnotator.java