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 * PUTSTATIC - Put static field in class
24 * <PRE>Stack: ..., value -> ...</PRE>
25 * OR
26 * <PRE>Stack: ..., value.word1, value.word2 -> ...</PRE>
27 *
28 * @version $Id: PUTSTATIC.java 386056 2006-03-15 11:31:56Z tcurdt $
29 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
30 */
31 public class PUTSTATIC extends FieldInstruction implements ExceptionThrower, PopInstruction {
32
33 /***
34 * Empty constructor needed for the Class.newInstance() statement in
35 * Instruction.readInstruction(). Not to be used otherwise.
36 */
37 PUTSTATIC() {
38 }
39
40
41 public PUTSTATIC(int index) {
42 super(Constants.PUTSTATIC, index);
43 }
44
45
46 public int consumeStack( ConstantPoolGen cpg ) {
47 return getFieldSize(cpg);
48 }
49
50
51 public Class[] getExceptions() {
52 Class[] cs = new Class[1 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
53 System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, cs, 0,
54 ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
55 cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
56 return cs;
57 }
58
59
60 /***
61 * Call corresponding visitor method(s). The order is:
62 * Call visitor methods of implemented interfaces first, then
63 * call methods according to the class hierarchy in descending order,
64 * i.e., the most specific visitXXX() call comes last.
65 *
66 * @param v Visitor object
67 */
68 public void accept( Visitor v ) {
69 v.visitExceptionThrower(this);
70 v.visitStackConsumer(this);
71 v.visitPopInstruction(this);
72 v.visitTypedInstruction(this);
73 v.visitLoadClass(this);
74 v.visitCPInstruction(this);
75 v.visitFieldOrMethod(this);
76 v.visitFieldInstruction(this);
77 v.visitPUTSTATIC(this);
78 }
79 }