KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > bcel > generic > PUTFIELD


1 /*
2  * Copyright 2000-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.bcel.generic;
18
19 import org.apache.bcel.Constants;
20 import org.apache.bcel.ExceptionConstants;
21
22 /**
23  * PUTFIELD - Put field in object
24  * <PRE>Stack: ..., objectref, value -&gt; ...</PRE>
25  * OR
26  * <PRE>Stack: ..., objectref, value.word1, value.word2 -&gt; ...</PRE>
27  *
28  * @version $Id: PUTFIELD.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 PUTFIELD extends FieldInstruction implements PopInstruction, ExceptionThrower {
32
33     /**
34      * Empty constructor needed for the Class.newInstance() statement in
35      * Instruction.readInstruction(). Not to be used otherwise.
36      */

37     PUTFIELD() {
38     }
39
40
41     public PUTFIELD(int index) {
42         super(Constants.PUTFIELD, index);
43     }
44
45
46     public int consumeStack( ConstantPoolGen cpg ) {
47         return getFieldSize(cpg) + 1;
48     }
49
50
51     public Class JavaDoc[] getExceptions() {
52         Class JavaDoc[] cs = new Class JavaDoc[2 + 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 + 1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
56         cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.NULL_POINTER_EXCEPTION;
57         return cs;
58     }
59
60
61     /**
62      * Call corresponding visitor method(s). The order is:
63      * Call visitor methods of implemented interfaces first, then
64      * call methods according to the class hierarchy in descending order,
65      * i.e., the most specific visitXXX() call comes last.
66      *
67      * @param v Visitor object
68      */

69     public void accept( Visitor v ) {
70         v.visitExceptionThrower(this);
71         v.visitStackConsumer(this);
72         v.visitPopInstruction(this);
73         v.visitTypedInstruction(this);
74         v.visitLoadClass(this);
75         v.visitCPInstruction(this);
76         v.visitFieldOrMethod(this);
77         v.visitFieldInstruction(this);
78         v.visitPUTFIELD(this);
79     }
80 }
81
Popular Tags