1 /*
2 * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
68 import com.sun.tools.classfile.Field;
69 import com.sun.tools.classfile.InnerClasses_attribute;
70 import com.sun.tools.classfile.InnerClasses_attribute.Info;
71 import com.sun.tools.classfile.Instruction;
72 import com.sun.tools.classfile.Instruction.TypeKind;
73 import com.sun.tools.classfile.LineNumberTable_attribute;
74 import com.sun.tools.classfile.LocalVariableTable_attribute;
75 import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
76 import com.sun.tools.classfile.Method;
77 import com.sun.tools.classfile.MethodParameters_attribute;
78 import com.sun.tools.classfile.Module_attribute;
79 import com.sun.tools.classfile.Module_attribute.ExportsEntry;
80 import com.sun.tools.classfile.Module_attribute.ProvidesEntry;
81 import com.sun.tools.classfile.Module_attribute.RequiresEntry;
82 import com.sun.tools.classfile.ModuleHashes_attribute;
83 import com.sun.tools.classfile.ModuleHashes_attribute.Entry;
84 import com.sun.tools.classfile.ModuleMainClass_attribute;
85 import com.sun.tools.classfile.ModuleResolution_attribute;
86 import com.sun.tools.classfile.ModuleTarget_attribute;
87 import com.sun.tools.classfile.ModulePackages_attribute;
88 import com.sun.tools.classfile.Opcode;
89 import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
90 import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
91 import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
92 import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
93 import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute;
94 import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute;
95 import com.sun.tools.classfile.Signature_attribute;
96 import com.sun.tools.classfile.SourceDebugExtension_attribute;
97 import com.sun.tools.classfile.SourceFile_attribute;
98 import com.sun.tools.classfile.SourceID_attribute;
99 import com.sun.tools.classfile.StackMapTable_attribute;
100 import com.sun.tools.classfile.StackMapTable_attribute.append_frame;
101 import com.sun.tools.classfile.StackMapTable_attribute.chop_frame;
102 import com.sun.tools.classfile.StackMapTable_attribute.full_frame;
103 import com.sun.tools.classfile.StackMapTable_attribute.same_frame;
104 import com.sun.tools.classfile.StackMapTable_attribute.same_frame_extended;
105 import com.sun.tools.classfile.StackMapTable_attribute.same_locals_1_stack_item_frame;
106 import com.sun.tools.classfile.StackMapTable_attribute.same_locals_1_stack_item_frame_extended;
107 import com.sun.tools.classfile.StackMap_attribute;
1547 e.trimToSize();
1548 p.add(e);
1549 return null;
1550 }
1551
1552 @Override
1553 public Element visitModuleResolution(ModuleResolution_attribute attr, Element p) {
1554 Element e = new Element("ModuleResolution");
1555 e.setAttr("flags", Integer.toString(attr.resolution_flags));
1556 e.trimToSize();
1557 p.add(e);
1558 return null;
1559 }
1560
1561 @Override
1562 public Element visitModuleTarget(ModuleTarget_attribute attr, Element p) {
1563 Element e = new Element(x.getCpString(attr.attribute_name_index));
1564 e.add(x.getCpString(attr.target_platform_index));
1565 e.trimToSize();
1566 p.add(e);
1567 return null;
1568 }
1569 }
1570
1571 class StackMapVisitor implements StackMapTable_attribute.stack_map_frame.Visitor<Element, Void> {
1572
1573 final ClassFile cf;
1574 final ClassReader x;
1575 final Element parent;
1576
1577 public StackMapVisitor(ClassReader x, ClassFile cf, Element parent) {
1578 this.x = x;
1579 this.cf = cf;
1580 this.parent = parent;
1581 }
1582
1583 public Element visit(StackMapTable_attribute.stack_map_frame frame) {
1584 return frame.accept(this, null);
1585 }
1586
|
1 /*
2 * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
68 import com.sun.tools.classfile.Field;
69 import com.sun.tools.classfile.InnerClasses_attribute;
70 import com.sun.tools.classfile.InnerClasses_attribute.Info;
71 import com.sun.tools.classfile.Instruction;
72 import com.sun.tools.classfile.Instruction.TypeKind;
73 import com.sun.tools.classfile.LineNumberTable_attribute;
74 import com.sun.tools.classfile.LocalVariableTable_attribute;
75 import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
76 import com.sun.tools.classfile.Method;
77 import com.sun.tools.classfile.MethodParameters_attribute;
78 import com.sun.tools.classfile.Module_attribute;
79 import com.sun.tools.classfile.Module_attribute.ExportsEntry;
80 import com.sun.tools.classfile.Module_attribute.ProvidesEntry;
81 import com.sun.tools.classfile.Module_attribute.RequiresEntry;
82 import com.sun.tools.classfile.ModuleHashes_attribute;
83 import com.sun.tools.classfile.ModuleHashes_attribute.Entry;
84 import com.sun.tools.classfile.ModuleMainClass_attribute;
85 import com.sun.tools.classfile.ModuleResolution_attribute;
86 import com.sun.tools.classfile.ModuleTarget_attribute;
87 import com.sun.tools.classfile.ModulePackages_attribute;
88 import com.sun.tools.classfile.NestHost_attribute;
89 import com.sun.tools.classfile.NestMembers_attribute;
90 import com.sun.tools.classfile.Opcode;
91 import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
92 import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
93 import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
94 import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
95 import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute;
96 import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute;
97 import com.sun.tools.classfile.Signature_attribute;
98 import com.sun.tools.classfile.SourceDebugExtension_attribute;
99 import com.sun.tools.classfile.SourceFile_attribute;
100 import com.sun.tools.classfile.SourceID_attribute;
101 import com.sun.tools.classfile.StackMapTable_attribute;
102 import com.sun.tools.classfile.StackMapTable_attribute.append_frame;
103 import com.sun.tools.classfile.StackMapTable_attribute.chop_frame;
104 import com.sun.tools.classfile.StackMapTable_attribute.full_frame;
105 import com.sun.tools.classfile.StackMapTable_attribute.same_frame;
106 import com.sun.tools.classfile.StackMapTable_attribute.same_frame_extended;
107 import com.sun.tools.classfile.StackMapTable_attribute.same_locals_1_stack_item_frame;
108 import com.sun.tools.classfile.StackMapTable_attribute.same_locals_1_stack_item_frame_extended;
109 import com.sun.tools.classfile.StackMap_attribute;
1549 e.trimToSize();
1550 p.add(e);
1551 return null;
1552 }
1553
1554 @Override
1555 public Element visitModuleResolution(ModuleResolution_attribute attr, Element p) {
1556 Element e = new Element("ModuleResolution");
1557 e.setAttr("flags", Integer.toString(attr.resolution_flags));
1558 e.trimToSize();
1559 p.add(e);
1560 return null;
1561 }
1562
1563 @Override
1564 public Element visitModuleTarget(ModuleTarget_attribute attr, Element p) {
1565 Element e = new Element(x.getCpString(attr.attribute_name_index));
1566 e.add(x.getCpString(attr.target_platform_index));
1567 e.trimToSize();
1568 p.add(e);
1569 return null;
1570 }
1571
1572 @Override
1573 public Element visitNestHost(NestHost_attribute attr, Element p) {
1574 String aname = x.getCpString(attr.attribute_name_index);
1575 String hname = x.getCpString(attr.top_index);
1576 Element se = new Element(aname);
1577 se.add(hname);
1578 se.trimToSize();
1579 p.add(se);
1580 return null;
1581 }
1582
1583 @Override
1584 public Element visitNestMembers(NestMembers_attribute attr, Element p) {
1585 Element ee = new Element(x.getCpString(attr.attribute_name_index));
1586 for (int idx : attr.members_indexes) {
1587 Element n = new Element("Item");
1588 n.setAttr("class", x.getCpString(idx));
1589 ee.add(n);
1590 }
1591 ee.trimToSize();
1592 p.add(ee);
1593 return null;
1594 }
1595 }
1596
1597 class StackMapVisitor implements StackMapTable_attribute.stack_map_frame.Visitor<Element, Void> {
1598
1599 final ClassFile cf;
1600 final ClassReader x;
1601 final Element parent;
1602
1603 public StackMapVisitor(ClassReader x, ClassFile cf, Element parent) {
1604 this.x = x;
1605 this.cf = cf;
1606 this.parent = parent;
1607 }
1608
1609 public Element visit(StackMapTable_attribute.stack_map_frame frame) {
1610 return frame.accept(this, null);
1611 }
1612
|