当前位置: 首页>>代码示例>>Java>>正文


Java Annotation类代码示例

本文整理汇总了Java中com.sun.tools.classfile.Annotation的典型用法代码示例。如果您正苦于以下问题:Java Annotation类的具体用法?Java Annotation怎么用?Java Annotation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Annotation类属于com.sun.tools.classfile包,在下文中一共展示了Annotation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseAnnotation

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:ClassReader.java

示例2: testAnnotation

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
public void testAnnotation(TestResult testResult, ClassFile classFile, Annotation annotation)
        throws ConstantPoolException {
    testResult.checkEquals(classFile.constant_pool.getUTF8Value(annotation.type_index),
            String.format("L%s;", annotationName), "Testing annotation name : " + annotationName);
    testResult.checkEquals(annotation.num_element_value_pairs,
            elementValues.size(), "Number of element values");
    if (!testResult.checkEquals(annotation.num_element_value_pairs, elementValues.size(),
            "Number of element value pairs")) {
        return;
    }
    for (int i = 0; i < annotation.num_element_value_pairs; ++i) {
        Annotation.element_value_pair pair = annotation.element_value_pairs[i];
        testResult.checkEquals(classFile.constant_pool.getUTF8Value(pair.element_name_index),
                elementValues.get(i).elementName, "element_name_index : " + elementValues.get(i).elementName);
        elementValues.get(i).elementValue.testElementValue(testResult, classFile, pair.value);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:TestAnnotationInfo.java

示例3: testElementValue

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
@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");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:TestAnnotationInfo.java

示例4: write

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
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(")");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:AnnotationWriter.java

示例5: visitRuntimeVisibleParameterAnnotations

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
@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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:ClassReader.java

示例6: visitRuntimeInvisibleParameterAnnotations

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
@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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:ClassReader.java

示例7: visitAnnotation

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
@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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:ClassReader.java

示例8: visitArray

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
@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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:ClassReader.java

示例9: createAnnotations

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
private Annotation[] createAnnotations(List<CPInfo> constantPool, List<AnnotationDescription> desc) {
    Annotation[] result = new Annotation[desc.size()];
    int i = 0;

    for (AnnotationDescription ad : desc) {
        result[i++] = createAnnotation(constantPool, ad);
    }

    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:CreateSymbols.java

示例10: createParameterAnnotations

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
private Annotation[][] createParameterAnnotations(List<CPInfo> constantPool, List<List<AnnotationDescription>> desc) {
    Annotation[][] result = new Annotation[desc.size()][];
    int i = 0;

    for (List<AnnotationDescription> paramAnnos : desc) {
        result[i++] = createAnnotations(constantPool, paramAnnos);
    }

    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:CreateSymbols.java

示例11: createAttributeValue

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
private element_value createAttributeValue(List<CPInfo> constantPool, Object value) {
    Pair<Integer, Character> constantPoolEntry = addConstant(constantPool, value, true);
    if (constantPoolEntry != null) {
        return new Primitive_element_value(constantPoolEntry.fst, constantPoolEntry.snd);
    } else if (value instanceof EnumConstant) {
        EnumConstant ec = (EnumConstant) value;
        return new Enum_element_value(addString(constantPool, ec.type),
                                      addString(constantPool, ec.constant),
                                      'e');
    } else if (value instanceof ClassConstant) {
        ClassConstant cc = (ClassConstant) value;
        return new Class_element_value(addString(constantPool, cc.type), 'c');
    } else if (value instanceof AnnotationDescription) {
        Annotation annotation = createAnnotation(constantPool, ((AnnotationDescription) value));
        return new Annotation_element_value(annotation, '@');
    } else if (value instanceof Collection) {
        @SuppressWarnings("unchecked")
                Collection<Object> array = (Collection<Object>) value;
        element_value[] values = new element_value[array.size()];
        int i = 0;

        for (Object elem : array) {
            values[i++] = createAttributeValue(constantPool, elem);
        }

        return new Array_element_value(values, '[');
    }
    throw new IllegalStateException(value.getClass().getName());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:CreateSymbols.java

示例12: annotations2Description

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
private List<AnnotationDescription> annotations2Description(ConstantPool cp, Attribute attr) throws ConstantPoolException {
    RuntimeAnnotations_attribute annotationsAttr = (RuntimeAnnotations_attribute) attr;
    List<AnnotationDescription> descs = new ArrayList<>();
    for (Annotation a : annotationsAttr.annotations) {
        descs.add(annotation2Description(cp, a));
    }
    return descs;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:CreateSymbols.java

示例13: parameterAnnotations2Description

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
private List<List<AnnotationDescription>> parameterAnnotations2Description(ConstantPool cp, Attribute attr) throws ConstantPoolException {
    RuntimeParameterAnnotations_attribute annotationsAttr =
            (RuntimeParameterAnnotations_attribute) attr;
    List<List<AnnotationDescription>> descs = new ArrayList<>();
    for (Annotation[] attrAnnos : annotationsAttr.parameter_annotations) {
        List<AnnotationDescription> paramDescs = new ArrayList<>();
        for (Annotation ann : attrAnnos) {
            paramDescs.add(annotation2Description(cp, ann));
        }
        descs.add(paramDescs);
    }
    return descs;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:CreateSymbols.java

示例14: annotation2Description

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
private AnnotationDescription annotation2Description(ConstantPool cp, Annotation a) throws ConstantPoolException {
    String annotationType = cp.getUTF8Value(a.type_index);
    Map<String, Object> values = new HashMap<>();

    for (element_value_pair e : a.element_value_pairs) {
        values.put(cp.getUTF8Value(e.element_name_index), convertElementValue(cp, e.value));
    }

    return new AnnotationDescription(annotationType, values);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:CreateSymbols.java

示例15: testElementValue

import com.sun.tools.classfile.Annotation; //导入依赖的package包/类
@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_Integer_info info =
            (ConstantPool.CONSTANT_Integer_info)
                    classFile.constant_pool.get(ev.const_value_index);
    testCase.checkEquals(info.value, Integer.parseInt(values[0]), "const_value_index");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:AnnotationDefaultVerifier.java


注:本文中的com.sun.tools.classfile.Annotation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。