use of com.sun.tools.classfile.TypeAnnotation in project checker-framework by typetools.
the class ComparisionException method compare.
public static boolean compare(List<Pair<String, TypeAnnotation.Position>> expectedAnnos, List<TypeAnnotation> actualAnnos, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
if (actualAnnos.size() != expectedAnnos.size()) {
throw new ComparisionException("Wrong number of annotations", expectedAnnos, actualAnnos);
}
for (Pair<String, TypeAnnotation.Position> e : expectedAnnos) {
String aName = e.first;
TypeAnnotation.Position expected = e.second;
TypeAnnotation actual = findAnnotation(aName, expected, actualAnnos, cf);
if (actual == null) {
throw new ComparisionException("Expected annotation not found: " + aName + " position: " + expected, expectedAnnos, actualAnnos);
}
}
return true;
}
use of com.sun.tools.classfile.TypeAnnotation in project jdk8u_jdk by JetBrains.
the class AnnotationsElementVisitor method visitRuntimeInvisibleTypeAnnotations.
@Override
public Element visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute rita, Element p) {
Element e = new Element(x.getCpString(rita.attribute_name_index));
for (TypeAnnotation pa : rita.annotations) {
parseTypeAnnotations(pa, e);
}
e.sort();
p.add(e);
return null;
}
use of com.sun.tools.classfile.TypeAnnotation in project jdk8u_jdk by JetBrains.
the class AnnotationsElementVisitor method visitRuntimeVisibleTypeAnnotations.
@Override
public Element visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute rvta, Element p) {
Element e = new Element(x.getCpString(rvta.attribute_name_index));
for (TypeAnnotation pa : rvta.annotations) {
parseTypeAnnotations(pa, e);
}
e.sort();
p.add(e);
return null;
}
use of com.sun.tools.classfile.TypeAnnotation in project checker-framework by typetools.
the class TADescriptions method runDriver.
protected void runDriver(Object object) throws Exception {
int passed = 0, failed = 0;
Class<?> clazz = object.getClass();
out.println("Tests for " + clazz.getName());
// Find methods
for (Method method : clazz.getMethods()) {
List<Pair<String, TypeAnnotation.Position>> expected = expectedOf(method);
if (expected == null) {
continue;
}
if (method.getReturnType() != String.class) {
throw new IllegalArgumentException("Test method needs to return a string: " + method);
}
String testClass = PersistUtil.testClassOf(method);
try {
String compact = (String) method.invoke(object);
String fullFile = PersistUtil.wrap(compact);
ClassFile cf = PersistUtil.compileAndReturn(fullFile, testClass);
List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
ReferenceInfoUtil.compare(expected, actual, cf);
out.println("PASSED: " + method.getName());
++passed;
} catch (Throwable e) {
out.println("FAILED: " + method.getName());
out.println(" " + e.toString());
++failed;
}
}
out.println();
int total = passed + failed;
out.println(total + " total tests: " + passed + " PASSED, " + failed + " FAILED");
out.flush();
if (failed != 0) {
throw new RuntimeException(failed + " tests failed");
}
}
Aggregations