Search in sources :

Example 1 with BootstrapMethods_attribute

use of com.sun.tools.classfile.BootstrapMethods_attribute in project jdk8u_jdk by JetBrains.

the class AnnotationsElementVisitor method visitBootstrapMethods.

@Override
public Element visitBootstrapMethods(BootstrapMethods_attribute bm, Element p) {
    Element e = new Element(x.getCpString(bm.attribute_name_index));
    for (BootstrapMethods_attribute.BootstrapMethodSpecifier bsm : bm.bootstrap_method_specifiers) {
        Element be = new Element("BootstrapMethodSpecifier");
        be.setAttr("ref", x.getCpString(bsm.bootstrap_method_ref));
        if (bsm.bootstrap_arguments.length > 0) {
            Element bme = new Element("MethodArguments");
            for (int index : bsm.bootstrap_arguments) {
                bme.add(x.getCpString(index));
            }
            bme.trimToSize();
            be.add(bme);
        }
        be.trimToSize();
        e.add(be);
    }
    e.trimToSize();
    if (!x.keepOrder) {
        e.sort();
    }
    p.add(e);
    return null;
}
Also used : Element(xmlkit.XMLKit.Element) BootstrapMethods_attribute(com.sun.tools.classfile.BootstrapMethods_attribute)

Example 2 with BootstrapMethods_attribute

use of com.sun.tools.classfile.BootstrapMethods_attribute in project jdk8u_jdk by JetBrains.

the class AnnotationsElementVisitor method readBSM.

private List<String> readBSM() {
    BootstrapMethods_attribute bsmAttr = (BootstrapMethods_attribute) cf.getAttribute(Attribute.BootstrapMethods);
    if (bsmAttr != null) {
        List<String> out = new ArrayList<>(bsmAttr.bootstrap_method_specifiers.length);
        for (BootstrapMethods_attribute.BootstrapMethodSpecifier bsms : bsmAttr.bootstrap_method_specifiers) {
            int index = bsms.bootstrap_method_ref;
            try {
                String value = slist.get(index);
                String bsmStr = value;
                if (value == null) {
                    value = visit(cfpool.get(index), index);
                    slist.set(index, value);
                }
                bsmStr = value;
                for (int idx : bsms.bootstrap_arguments) {
                    value = slist.get(idx);
                    if (value == null) {
                        value = visit(cfpool.get(idx), idx);
                        slist.set(idx, value);
                    }
                    bsmStr = bsmStr.concat("," + value);
                }
                out.add(bsmStr);
            } catch (InvalidIndex ex) {
                ex.printStackTrace();
            }
        }
        return out;
    }
    return new ArrayList<>(0);
}
Also used : BootstrapMethods_attribute(com.sun.tools.classfile.BootstrapMethods_attribute)

Aggregations

BootstrapMethods_attribute (com.sun.tools.classfile.BootstrapMethods_attribute)2 Element (xmlkit.XMLKit.Element)1