19 * limitations under the License. |
19 * limitations under the License. |
20 */ |
20 */ |
21 |
21 |
22 package com.sun.org.apache.bcel.internal.generic; |
22 package com.sun.org.apache.bcel.internal.generic; |
23 |
23 |
24 import com.sun.org.apache.bcel.internal.Constants; |
24 import java.io.DataOutputStream; |
25 import com.sun.org.apache.bcel.internal.ExceptionConstants; |
25 import java.io.IOException; |
|
26 |
|
27 import com.sun.org.apache.bcel.internal.Const; |
|
28 import com.sun.org.apache.bcel.internal.ExceptionConst; |
26 |
29 |
27 /** |
30 /** |
28 * INVOKESTATIC - Invoke a class (static) method |
31 * INVOKESTATIC - Invoke a class (static) method |
29 * |
32 * |
30 * <PRE>Stack: ..., [arg1, [arg2 ...]] -> ...</PRE> |
33 * <PRE>Stack: ..., [arg1, [arg2 ...]] -> ...</PRE> |
31 * |
34 * |
32 * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> |
35 * @version $Id: INVOKESTATIC.java 1747278 2016-06-07 17:28:43Z britter $ |
|
36 * @see |
|
37 * <a href="http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokestatic"> |
|
38 * The invokestatic instruction in The Java Virtual Machine Specification</a> |
33 */ |
39 */ |
34 public class INVOKESTATIC extends InvokeInstruction { |
40 public class INVOKESTATIC extends InvokeInstruction { |
35 /** |
|
36 * Empty constructor needed for the Class.newInstance() statement in |
|
37 * Instruction.readInstruction(). Not to be used otherwise. |
|
38 */ |
|
39 INVOKESTATIC() {} |
|
40 |
41 |
41 public INVOKESTATIC(int index) { |
42 /** |
42 super(Constants.INVOKESTATIC, index); |
43 * Empty constructor needed for the Class.newInstance() statement in |
43 } |
44 * Instruction.readInstruction(). Not to be used otherwise. |
44 |
45 */ |
45 public Class[] getExceptions() { |
46 INVOKESTATIC() { |
46 Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length]; |
47 } |
47 |
|
48 System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, |
|
49 cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length); |
|
50 |
|
51 cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.UNSATISFIED_LINK_ERROR; |
|
52 cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR; |
|
53 |
|
54 return cs; |
|
55 } |
|
56 |
48 |
57 |
49 |
58 /** |
50 public INVOKESTATIC(final int index) { |
59 * Call corresponding visitor method(s). The order is: |
51 super(Const.INVOKESTATIC, index); |
60 * Call visitor methods of implemented interfaces first, then |
52 } |
61 * call methods according to the class hierarchy in descending order, |
53 |
62 * i.e., the most specific visitXXX() call comes last. |
54 |
63 * |
55 /** |
64 * @param v Visitor object |
56 * Dump instruction as byte code to stream out. |
65 */ |
57 * @param out Output stream |
66 public void accept(Visitor v) { |
58 */ |
67 v.visitExceptionThrower(this); |
59 @Override |
68 v.visitTypedInstruction(this); |
60 public void dump( final DataOutputStream out ) throws IOException { |
69 v.visitStackConsumer(this); |
61 out.writeByte(super.getOpcode()); |
70 v.visitStackProducer(this); |
62 out.writeShort(super.getIndex()); |
71 v.visitLoadClass(this); |
63 } |
72 v.visitCPInstruction(this); |
64 |
73 v.visitFieldOrMethod(this); |
65 @Override |
74 v.visitInvokeInstruction(this); |
66 public Class<?>[] getExceptions() { |
75 v.visitINVOKESTATIC(this); |
67 return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, |
76 } |
68 ExceptionConst.UNSATISFIED_LINK_ERROR, |
|
69 ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); |
|
70 } |
|
71 |
|
72 |
|
73 /** |
|
74 * Call corresponding visitor method(s). The order is: |
|
75 * Call visitor methods of implemented interfaces first, then |
|
76 * call methods according to the class hierarchy in descending order, |
|
77 * i.e., the most specific visitXXX() call comes last. |
|
78 * |
|
79 * @param v Visitor object |
|
80 */ |
|
81 @Override |
|
82 public void accept( final Visitor v ) { |
|
83 v.visitExceptionThrower(this); |
|
84 v.visitTypedInstruction(this); |
|
85 v.visitStackConsumer(this); |
|
86 v.visitStackProducer(this); |
|
87 v.visitLoadClass(this); |
|
88 v.visitCPInstruction(this); |
|
89 v.visitFieldOrMethod(this); |
|
90 v.visitInvokeInstruction(this); |
|
91 v.visitINVOKESTATIC(this); |
|
92 } |
77 } |
93 } |