Java Code Examples for com.sun.tools.classfile.Annotation

The following examples show how to use com.sun.tools.classfile.Annotation. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk8u-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example 2
Source Project: openjdk-8   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example 3
@Override
public void testElementValue(
        TestResult testResult,
        ClassFile classFile,
        Annotation.element_value element_value)
        throws ConstantPoolException {
    testTag(testResult, element_value.tag);
    Annotation ev = ((Annotation.Annotation_element_value) element_value).annotation_value;
    testResult.checkEquals(
            classFile.constant_pool.getUTF8Info(ev.type_index).value,
            String.format("L%s;", annotationName),
            "type_index");
    for (int i = 0; i < ev.num_element_value_pairs; ++i) {
        Annotation.element_value_pair pair = ev.element_value_pairs[i];
        Pair expectedPair = annotation.elementValues.get(i);
        expectedPair.elementValue.testElementValue(testResult, classFile, pair.value);
        testResult.checkEquals(
                classFile.constant_pool.getUTF8Info(pair.element_name_index).value,
                expectedPair.elementName,
                "element_name_index");
    }
}
 
Example 4
Source Project: openjdk-jdk8u   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example 5
Source Project: hottub   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example 6
Source Project: jdk8u-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example 7
@Override
public void testElementValue(TestResult testResult,
                             ClassFile classFile,
                             Annotation.element_value element_value)
        throws ConstantPool.InvalidIndex {
    testTag(testResult, element_value.tag);
    Annotation.Primitive_element_value ev =
            (Annotation.Primitive_element_value) element_value;
    ConstantPool.CONSTANT_Float_info info =
            (ConstantPool.CONSTANT_Float_info) classFile.constant_pool.get(ev.const_value_index);
    testResult.checkEquals(info.value, value, "const_value_index");
}
 
Example 8
Source Project: dragonwell8_jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute rvpa,
                                                       Element p) {
    Element e = new Element(x.getCpString(rvpa.attribute_name_index));
    for (Annotation[] pa : rvpa.parameter_annotations) {
       parseAnnotations(pa, e);
    }
    p.add(e);
    return null;
}
 
Example 9
public void write(Annotation annot, boolean resolveIndices) {
    writeDescriptor(annot.type_index, resolveIndices);
    boolean showParens = annot.num_element_value_pairs > 0 || !resolveIndices;
    if (showParens)
        print("(");
    for (int i = 0; i < annot.num_element_value_pairs; i++) {
        if (i > 0)
            print(",");
        write(annot.element_value_pairs[i], resolveIndices);
    }
    if (showParens)
        print(")");
}
 
Example 10
Source Project: TencentKona-8   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute rvpa,
                                                       Element p) {
    Element e = new Element(x.getCpString(rvpa.attribute_name_index));
    for (Annotation[] pa : rvpa.parameter_annotations) {
       parseAnnotations(pa, e);
    }
    p.add(e);
    return null;
}
 
Example 11
Source Project: TencentKona-8   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 12
@Override
public void testElementValue(TestResult testResult,
                             ClassFile classFile,
                             Annotation.element_value element_value)
        throws ConstantPoolException {
    testTag(testResult, element_value.tag);
    Annotation.Primitive_element_value ev =
            (Annotation.Primitive_element_value) element_value;
    ConstantPool.CONSTANT_Integer_info info =
            (ConstantPool.CONSTANT_Integer_info)
                    classFile.constant_pool.get(ev.const_value_index);
    testResult.checkEquals(info.value, (int) value, "const_value_index : " + value);
}
 
Example 13
@Override
public void testElementValue(
        TestResult testCase,
        ClassFile classFile,
        Annotation.element_value element_value,
        String[] values)
        throws ConstantPool.InvalidIndex, ConstantPool.UnexpectedEntry {
    Annotation.Enum_element_value ev = (Annotation.Enum_element_value) element_value;
    testCase.checkEquals(classFile.constant_pool.getUTF8Info(ev.type_name_index).value,
            values[0], "type_name_index");
    testCase.checkEquals(classFile.constant_pool.getUTF8Info(ev.const_name_index).value,
            values[1], "const_name_index");
}
 
Example 14
Source Project: TencentKona-8   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitArray(Array_element_value a, Element p) {
 Element el = new Element("Array");
    for (Annotation.element_value v : a.values) {
       Element child = visit(v, el);
       if (child != null) {
           el.add(child);
       }
    }
    el.trimToSize();
    return el;
}
 
Example 15
Source Project: jdk8u-dev-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 16
@Override
public void testElementValue(TestResult testResult,
                             ClassFile classFile,
                             Annotation.element_value element_value)
        throws ConstantPoolException {
    testTag(testResult, element_value.tag);
    Annotation.Primitive_element_value ev =
            (Annotation.Primitive_element_value) element_value;
    ConstantPool.CONSTANT_Double_info info = (ConstantPool.CONSTANT_Double_info)
            classFile.constant_pool.get(ev.const_value_index);
    testResult.checkEquals(info.value, value, "const_value_index");
}
 
Example 17
Source Project: jdk8u60   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute rvpa,
                                                       Element p) {
    Element e = new Element(x.getCpString(rvpa.attribute_name_index));
    for (Annotation[] pa : rvpa.parameter_annotations) {
       parseAnnotations(pa, e);
    }
    p.add(e);
    return null;
}
 
Example 18
Source Project: openjdk-8-source   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 19
Source Project: hottub   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 20
@Override
public void testElementValue(
        TestResult testCase,
        ClassFile classFile,
        Annotation.element_value element_value,
        String[] values) throws ConstantPool.InvalidIndex {
    Annotation.Primitive_element_value ev =
            (Annotation.Primitive_element_value) element_value;
    ConstantPool.CONSTANT_Float_info info =
            (ConstantPool.CONSTANT_Float_info)
                    classFile.constant_pool.get(ev.const_value_index);
    testCase.checkEquals(info.value, Float.parseFloat(values[0]), "const_value_index");
}
 
Example 21
public void write(Annotation annot, boolean resolveIndices) {
    writeDescriptor(annot.type_index, resolveIndices);
    boolean showParens = annot.num_element_value_pairs > 0 || !resolveIndices;
    if (showParens)
        print("(");
    for (int i = 0; i < annot.num_element_value_pairs; i++) {
        if (i > 0)
            print(",");
        write(annot.element_value_pairs[i], resolveIndices);
    }
    if (showParens)
        print(")");
}
 
Example 22
Source Project: openjdk-jdk9   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute rvpa,
                                                       Element p) {
    Element e = new Element(x.getCpString(rvpa.attribute_name_index));
    for (Annotation[] pa : rvpa.parameter_annotations) {
       parseAnnotations(pa, e);
    }
    p.add(e);
    return null;
}
 
Example 23
Source Project: openjdk-8-source   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 24
Source Project: openjdk-8-source   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitArray(Array_element_value a, Element p) {
 Element el = new Element("Array");
    for (Annotation.element_value v : a.values) {
       Element child = visit(v, el);
       if (child != null) {
           el.add(child);
       }
    }
    el.trimToSize();
    return el;
}
 
Example 25
Source Project: openjdk-jdk8u   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 26
Source Project: openjdk-jdk8u   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitArray(Array_element_value a, Element p) {
 Element el = new Element("Array");
    for (Annotation.element_value v : a.values) {
       Element child = visit(v, el);
       if (child != null) {
           el.add(child);
       }
    }
    el.trimToSize();
    return el;
}
 
Example 27
public void write(Annotation annot, boolean resolveIndices) {
    writeDescriptor(annot.type_index, resolveIndices);
    boolean showParens = annot.num_element_value_pairs > 0 || !resolveIndices;
    if (showParens)
        print("(");
    for (int i = 0; i < annot.num_element_value_pairs; i++) {
        if (i > 0)
            print(",");
        write(annot.element_value_pairs[i], resolveIndices);
    }
    if (showParens)
        print(")");
}
 
Example 28
Source Project: jdk8u-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 29
Source Project: openjdk-8   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 30
@Override
public Element visitArray(Array_element_value a, Element p) {
 Element el = new Element("Array");
    for (Annotation.element_value v : a.values) {
       Element child = visit(v, el);
       if (child != null) {
           el.add(child);
       }
    }
    el.trimToSize();
    return el;
}