Search in sources :

Example 71 with Element

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

the class AnnotationsElementVisitor method visitRuntimeVisibleTypeAnnotations.

@Override
public Element visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute rvta, Element p) {
    Element e = new Element(x.getCpString(rvta.attribute_name_index));
    for (TypeAnnotation pa : rvta.annotations) {
        parseTypeAnnotations(pa, e);
    }
    e.sort();
    p.add(e);
    return null;
}
Also used : TypeAnnotation(com.sun.tools.classfile.TypeAnnotation) Element(xmlkit.XMLKit.Element)

Example 72 with Element

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

the class AnnotationsElementVisitor method visitString.

@Override
public String visitString(CONSTANT_String_info c, Integer p) {
    try {
        String value = slist.get(p);
        if (value == null) {
            value = c.getString();
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_String", new String[] { "id", p.toString() }, value));
        }
        return value;
    } catch (ConstantPoolException ex) {
        throw new RuntimeException("Fatal error", ex);
    }
}
Also used : Element(xmlkit.XMLKit.Element) ConstantPoolException(com.sun.tools.classfile.ConstantPoolException)

Example 73 with Element

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

the class AnnotationsElementVisitor method doStream.

private static void doStream(String a, InputStream in, File dest, ClassReader options, String encoding) throws IOException {
    File f = new File(a);
    ClassReader cr = new ClassReader(options);
    Element e;
    if (options.verbose) {
        System.out.println("Reading " + f);
    }
    e = cr.readFrom(in);
    OutputStream out;
    if (dest == null) {
        out = System.out;
    } else {
        File outf = new File(dest, f.isAbsolute() ? f.getName() : f.getPath());
        String outName = outf.getName();
        File outSubdir = outf.getParentFile();
        outSubdir.mkdirs();
        int extPos = outName.lastIndexOf('.');
        if (extPos > 0) {
            outf = new File(outSubdir, outName.substring(0, extPos) + ".xml");
        }
        out = new FileOutputStream(outf);
    }
    Writer outw = makeWriter(out, encoding);
    if (options.pretty || !options.keepOrder) {
        e.writePrettyTo(outw);
    } else {
        e.writeTo(outw);
    }
    if (out == System.out) {
        outw.write("\n");
        outw.flush();
    } else {
        outw.close();
    }
}
Also used : Element(xmlkit.XMLKit.Element) JarFile(java.util.jar.JarFile) ClassFile(com.sun.tools.classfile.ClassFile)

Example 74 with Element

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

the class AnnotationsElementVisitor method readFields.

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

Example 75 with Element

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

the class AnnotationsElementVisitor method visit_same_frame.

@Override
public Element visit_same_frame(same_frame sm_frm, Void p) {
    Element e = new Element("SameFrame");
    e.setAttr("tag", "" + sm_frm.frame_type);
    return e;
}
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