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 org.apache.bcel.Constants;
20 import org.apache.bcel.ExceptionConstants;
21
22 /***
23 * INVOKEVIRTUAL - Invoke instance method; dispatch based on class
24 *
25 * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -> ...</PRE>
26 *
27 * @version $Id: INVOKEVIRTUAL.java 386056 2006-03-15 11:31:56Z tcurdt $
28 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29 */
30 public class INVOKEVIRTUAL extends InvokeInstruction {
31
32 /***
33 * Empty constructor needed for the Class.newInstance() statement in
34 * Instruction.readInstruction(). Not to be used otherwise.
35 */
36 INVOKEVIRTUAL() {
37 }
38
39
40 public INVOKEVIRTUAL(int index) {
41 super(Constants.INVOKEVIRTUAL, index);
42 }
43
44
45 public Class[] getExceptions() {
46 Class[] cs = new Class[4 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
47 System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, cs, 0,
48 ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
49 cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 3] = ExceptionConstants.UNSATISFIED_LINK_ERROR;
50 cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 2] = ExceptionConstants.ABSTRACT_METHOD_ERROR;
51 cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
52 cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.NULL_POINTER_EXCEPTION;
53 return cs;
54 }
55
56
57 /***
58 * Call corresponding visitor method(s). The order is:
59 * Call visitor methods of implemented interfaces first, then
60 * call methods according to the class hierarchy in descending order,
61 * i.e., the most specific visitXXX() call comes last.
62 *
63 * @param v Visitor object
64 */
65 public void accept( Visitor v ) {
66 v.visitExceptionThrower(this);
67 v.visitTypedInstruction(this);
68 v.visitStackConsumer(this);
69 v.visitStackProducer(this);
70 v.visitLoadClass(this);
71 v.visitCPInstruction(this);
72 v.visitFieldOrMethod(this);
73 v.visitInvokeInstruction(this);
74 v.visitINVOKEVIRTUAL(this);
75 }
76 }