aboutsummaryrefslogtreecommitdiffstats
path: root/abi-check-plugin/src/main/java/com/yahoo/abicheck/collector/AnnotationCollector.java
blob: cc2b37f13c930b79e3ed00e1af0569e8164a5a3c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.yahoo.abicheck.collector;

import java.util.HashSet;
import java.util.Set;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;

public class AnnotationCollector extends ClassVisitor {

  private final Set<String> annotations = new HashSet<>();

  public AnnotationCollector() {
    super(Opcodes.ASM7);
  }

  @Override
  public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
    annotations.add(Type.getType(descriptor).getClassName());
    return null;
  }

  public Set<String> getAnnotations() {
    return annotations;
  }
}