use of com.sun.tools.classfile.Annotation in project jdk8u_jdk by JetBrains.
the class AnnotationsElementVisitor method visitAnnotation.
@Override
public Element visitAnnotation(Annotation_element_value a, Element p) {
Element el = new Element("Annotation");
Annotation anno = a.annotation_value;
for (Annotation.element_value_pair evp : anno.element_value_pairs) {
Element child = visit(evp.value, el);
if (child != null) {
el.add(child);
}
}
el.trimToSize();
return el;
}
use of com.sun.tools.classfile.Annotation in project jdk8u_jdk by JetBrains.
the class AnnotationsElementVisitor method parseAnnotation.
private void parseAnnotation(Annotation anno, Element p) {
Element ea = new Element("Annotation");
ea.setAttr("name", "" + x.getCpString(anno.type_index));
for (Annotation.element_value_pair evp : anno.element_value_pairs) {
Element evpe = new Element("Element");
evpe.setAttr("tag", "" + evp.value.tag);
evpe.setAttr("value", x.getCpString(evp.element_name_index));
Element child = aev.visit(evp.value, evpe);
if (child != null) {
evpe.add(child);
}
ea.add(evpe);
}
ea.trimToSize();
p.add(ea);
}
use of com.sun.tools.classfile.Annotation in project jdk8u_jdk by JetBrains.
the class AnnotationsElementVisitor method visitRuntimeInvisibleParameterAnnotations.
@Override
public Element visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute ripa, Element p) {
Element e = new Element(x.getCpString(ripa.attribute_name_index));
for (Annotation[] pa : ripa.parameter_annotations) {
parseAnnotations(pa, e);
}
p.add(e);
return null;
}
use of com.sun.tools.classfile.Annotation in project checker-framework by typetools.
the class ComparisionException method findAnnotations.
/**
* Test the result of Attributes.getIndex according to expectations encoded in the method's
* name.
*/
private static void findAnnotations(ClassFile cf, Method m, String name, List<Annotation> annos) {
int index = m.attributes.getIndex(cf.constant_pool, name);
if (index != -1) {
Attribute attr = m.attributes.get(index);
assert attr instanceof RuntimeAnnotations_attribute;
RuntimeAnnotations_attribute tAttr = (RuntimeAnnotations_attribute) attr;
for (Annotation an : tAttr.annotations) {
if (!containsName(annos, an, cf)) {
annos.add(an);
}
}
}
}
use of com.sun.tools.classfile.Annotation in project checker-framework by typetools.
the class ADescriptions 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<String> 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<Annotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
String diagnostic = String.join("; ", "Tests for " + clazz.getName(), "compact=" + compact, "fullFile=" + fullFile, "testClass=" + testClass);
ReferenceInfoUtil.compare(expected, actual, cf, diagnostic);
out.println("PASSED: " + method.getName());
++passed;
} catch (Throwable e) {
out.println("FAILED: " + method.getName());
out.println(" " + e);
++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