Search in sources :

Example 56 with Element

use of xmlkit.XMLKit.Element in project jdk8u_jdk by JetBrains.

the class AnnotationsElementVisitor method readMethods.

private void readMethods(ClassFile c, Element klass) throws IOException {
    int len = c.methods.length;
    Element methods = new Element(len);
    for (Method m : c.methods) {
        Element member = new Element("Method");
        member.setAttr("name", getCpString(m.name_index));
        member.setAttr("type", getCpString(m.descriptor.index));
        member.setAttr("flags", flagString(m.access_flags.flags, member));
        readAttributesFor(c, m.attributes, member);
        member.trimToSize();
        methods.add(member);
    }
    if (!keepOrder) {
        methods.sort();
    }
    klass.addAll(methods);
}
Also used : Element(xmlkit.XMLKit.Element) Method(com.sun.tools.classfile.Method)

Example 57 with Element

use of xmlkit.XMLKit.Element in project jdk8u_jdk by JetBrains.

the class AnnotationsElementVisitor method visitValue.

@Override
public Element visitValue(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + i1);
    return ie;
}
Also used : Element(xmlkit.XMLKit.Element)

Example 58 with Element

use of xmlkit.XMLKit.Element in project jdk8u_jdk by JetBrains.

the class AnnotationsElementVisitor method parsePosition.

private void parsePosition(Position ap, Element p) {
    Element te = new Element();
    switch(ap.type) {
        case // 0x00
        CLASS_TYPE_PARAMETER:
            te.setName("CLASS_TYPE_PARAMETER");
            te.setAttr("idx", "" + ap.parameter_index);
            break;
        case // 0x01
        METHOD_TYPE_PARAMETER:
            te.setName("METHOD_TYPE_PARAMETER");
            te.setAttr("idx", "" + ap.parameter_index);
            break;
        case // 0x10
        CLASS_EXTENDS:
            te.setName("CLASS_EXTENDS");
            te.setAttr("idx", "" + ap.type_index);
            break;
        case // 0x11
        CLASS_TYPE_PARAMETER_BOUND:
            te.setName("CLASS_TYPE_PARAMETER_BOUND");
            te.setAttr("idx1", "" + ap.parameter_index);
            te.setAttr("idx2", "" + ap.bound_index);
            break;
        case // 0x12
        METHOD_TYPE_PARAMETER_BOUND:
            te.setName("METHOD_TYPE_PARAMETER_BOUND");
            te.setAttr("idx1", "" + ap.parameter_index);
            te.setAttr("idx2", "" + ap.bound_index);
            break;
        case // 0x13
        FIELD:
            te.setName("FIELD");
            break;
        case // 0x14
        METHOD_RETURN:
            te.setName("METHOD_RETURN");
            break;
        case // 0x15
        METHOD_RECEIVER:
            te.setName("METHOD_RECEIVER");
            break;
        case // 0x16
        METHOD_FORMAL_PARAMETER:
            te.setName("METHOD_FORMAL_PARAMETER");
            te.setAttr("idx", "" + ap.parameter_index);
            break;
        case // 0x17
        THROWS:
            te.setName("THROWS");
            te.setAttr("idx", "" + ap.type_index);
            break;
        case // 0x40
        LOCAL_VARIABLE:
            te.setName("LOCAL_VARIABLE");
            for (int i = 0; i < ap.lvarIndex.length; i++) {
                te.setAttr("lvar_idx_" + i, "" + ap.lvarIndex[i]);
                te.setAttr("lvar_len_" + i, "" + ap.lvarLength[i]);
                te.setAttr("lvar_off_" + i, "" + ap.lvarOffset[i]);
            }
            break;
        case // 0x41
        RESOURCE_VARIABLE:
            te.setName("RESOURCE_VARIABLE");
            for (int i = 0; i < ap.lvarIndex.length; i++) {
                te.setAttr("lvar_idx_" + i, "" + ap.lvarIndex[i]);
                te.setAttr("lvar_len_" + i, "" + ap.lvarLength[i]);
                te.setAttr("lvar_off_" + i, "" + ap.lvarOffset[i]);
            }
            break;
        case // 0x42
        EXCEPTION_PARAMETER:
            te.setName("EXCEPTION_PARAMETER");
            te.setAttr("idx", "" + ap.exception_index);
            break;
        case // 0x43
        INSTANCEOF:
            te.setName("INSTANCE_OF");
            te.setAttr("off", "" + ap.offset);
            break;
        case // 0x44
        NEW:
            te.setName("NEW");
            te.setAttr("off", "" + ap.offset);
            break;
        case // 0x45
        CONSTRUCTOR_REFERENCE:
            te.setName("CONSTRUCTOR_REFERENCE_RECEIVER");
            te.setAttr("off", "" + ap.offset);
            break;
        case // 0x46
        METHOD_REFERENCE:
            te.setName("METHOD_REFERENCE_RECEIVER");
            te.setAttr("off", "" + ap.offset);
            break;
        case // 0x47
        CAST:
            te.setName("CAST");
            te.setAttr("off", "" + ap.offset);
            te.setAttr("idx", "" + ap.type_index);
            break;
        case // 0x48
        CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
            te.setName("CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT");
            te.setAttr("off", "" + ap.offset);
            te.setAttr("idx", "" + ap.type_index);
            break;
        case // 0x49
        METHOD_INVOCATION_TYPE_ARGUMENT:
            te.setName("METHOD_INVOCATION_TYPE_ARGUMENT");
            te.setAttr("off", "" + ap.offset);
            te.setAttr("idx", "" + ap.type_index);
            break;
        case // 0x4A
        CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
            te.setName("CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT");
            te.setAttr("off", "" + ap.offset);
            te.setAttr("idx", "" + ap.type_index);
            break;
        case // 0x4B
        METHOD_REFERENCE_TYPE_ARGUMENT:
            te.setName("METHOD_REFERENCE_TYPE_ARGUMENT");
            te.setAttr("off", "" + ap.offset);
            te.setAttr("idx", "" + ap.type_index);
            break;
        default:
            throw new RuntimeException("not implemented");
    }
    te.trimToSize();
    p.add(te);
}
Also used : Element(xmlkit.XMLKit.Element)

Example 59 with Element

use of xmlkit.XMLKit.Element in project jdk8u_jdk by JetBrains.

the class AnnotationsElementVisitor method visitInteger.

@Override
public String visitInteger(CONSTANT_Integer_info cnstnt, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        value = Integer.toString(cnstnt.value);
        slist.set(p, value);
        xpool.add(new Element("CONSTANT_Integer", new String[] { "id", p.toString() }, value));
    }
    return value;
}
Also used : Element(xmlkit.XMLKit.Element)

Example 60 with Element

use of xmlkit.XMLKit.Element in project jdk8u_jdk by JetBrains.

the class AnnotationsElementVisitor method visitFloat.

@Override
public String visitFloat(CONSTANT_Float_info c, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        value = Float.toString(c.value);
        slist.set(p, value);
        xpool.add(new Element("CONSTANT_Float", new String[] { "id", p.toString() }, value));
    }
    return value;
}
Also used : Element(xmlkit.XMLKit.Element)

Aggregations

Element (xmlkit.XMLKit.Element)77 ConstantPoolException (com.sun.tools.classfile.ConstantPoolException)8 TypeAnnotation (com.sun.tools.classfile.TypeAnnotation)7 Annotation (com.sun.tools.classfile.Annotation)5 StackMapTable_attribute (com.sun.tools.classfile.StackMapTable_attribute)2 AccessFlags (com.sun.tools.classfile.AccessFlags)1 Attribute (com.sun.tools.classfile.Attribute)1 BootstrapMethods_attribute (com.sun.tools.classfile.BootstrapMethods_attribute)1 CharacterRangeTable_attribute (com.sun.tools.classfile.CharacterRangeTable_attribute)1 ClassFile (com.sun.tools.classfile.ClassFile)1 Code_attribute (com.sun.tools.classfile.Code_attribute)1 DefaultAttribute (com.sun.tools.classfile.DefaultAttribute)1 Field (com.sun.tools.classfile.Field)1 Info (com.sun.tools.classfile.InnerClasses_attribute.Info)1 Instruction (com.sun.tools.classfile.Instruction)1 LineNumberTable_attribute (com.sun.tools.classfile.LineNumberTable_attribute)1 LocalVariableTable_attribute (com.sun.tools.classfile.LocalVariableTable_attribute)1 LocalVariableTypeTable_attribute (com.sun.tools.classfile.LocalVariableTypeTable_attribute)1 Method (com.sun.tools.classfile.Method)1 MethodParameters_attribute (com.sun.tools.classfile.MethodParameters_attribute)1