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