1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.bcel.generic;
18
19 import java.io.DataOutputStream;
20 import java.io.IOException;
21
22 import org.apache.bcel.Const;
23 import org.apache.bcel.ExceptionConst;
24 import org.apache.bcel.classfile.ConstantInvokeDynamic;
25 import org.apache.bcel.classfile.ConstantNameAndType;
26 import org.apache.bcel.classfile.ConstantPool;
27 import org.apache.bcel.util.ByteSequence;
28
29
30
31
32
33
34
35
36
37 public class INVOKEDYNAMIC extends InvokeInstruction {
38
39
40
41
42 INVOKEDYNAMIC() {
43 }
44
45 public INVOKEDYNAMIC(final int index) {
46 super(Const.INVOKEDYNAMIC, index);
47 }
48
49
50
51
52
53
54
55 @Override
56 public void accept(final Visitor v) {
57 v.visitExceptionThrower(this);
58 v.visitTypedInstruction(this);
59 v.visitStackConsumer(this);
60 v.visitStackProducer(this);
61 v.visitLoadClass(this);
62 v.visitCPInstruction(this);
63 v.visitFieldOrMethod(this);
64 v.visitInvokeInstruction(this);
65 v.visitINVOKEDYNAMIC(this);
66 }
67
68
69
70
71
72
73 @Override
74 public void dump(final DataOutputStream out) throws IOException {
75 out.writeByte(super.getOpcode());
76 out.writeShort(super.getIndex());
77 out.writeByte(0);
78 out.writeByte(0);
79 }
80
81
82
83
84
85
86
87 @Override
88 public String getClassName(final ConstantPoolGen cpg) {
89 final ConstantPool cp = cpg.getConstantPool();
90 final ConstantInvokeDynamic cid = cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic, ConstantInvokeDynamic.class);
91 return cp.getConstant(cid.getNameAndTypeIndex(), ConstantNameAndType.class).getName(cp);
92 }
93
94 @Override
95 public Class<?>[] getExceptions() {
96 return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_INTERFACE_METHOD_RESOLUTION, ExceptionConst.UNSATISFIED_LINK_ERROR,
97 ExceptionConst.ABSTRACT_METHOD_ERROR, ExceptionConst.ILLEGAL_ACCESS_ERROR, ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
98 }
99
100
101
102
103
104
105
106
107
108 @Override
109 public ReferenceType getReferenceType(final ConstantPoolGen cpg) {
110 return new ObjectType(Object.class.getName());
111 }
112
113
114
115
116 @Override
117 protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
118 super.initFromFile(bytes, wide);
119 super.setLength(5);
120 bytes.readByte();
121 bytes.readByte();
122 }
123
124 }