< prev index next >

src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/GETFIELD.java

Print this page


   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.bcel.internal.generic;
  23 
  24 
  25 import com.sun.org.apache.bcel.internal.Constants;
  26 import com.sun.org.apache.bcel.internal.ExceptionConstants;
  27 
  28 /**
  29  * GETFIELD - Fetch field from object
  30  * <PRE>Stack: ..., objectref -&gt; ..., value</PRE>
  31  * OR
  32  * <PRE>Stack: ..., objectref -&gt; ..., value.word1, value.word2</PRE>
  33  *
  34  * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  35  */
  36 public class GETFIELD extends FieldInstruction
  37   implements ExceptionThrower, StackConsumer, StackProducer {

  38   /**
  39    * Empty constructor needed for the Class.newInstance() statement in
  40    * Instruction.readInstruction(). Not to be used otherwise.
  41    */
  42   GETFIELD() {}
  43 
  44   public GETFIELD(int index) {
  45     super(Constants.GETFIELD, index);
  46   }
  47 
  48   public int produceStack(ConstantPoolGen cpg) { return getFieldSize(cpg); }
  49 
  50   public Class[] getExceptions() {
  51     Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
  52 
  53     System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0,
  54                      cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
  55 
  56     cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] =
  57       ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
  58     cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] =
  59       ExceptionConstants.NULL_POINTER_EXCEPTION;
  60 
  61     return cs;


  62   }
  63 






  64 
  65   /**
  66    * Call corresponding visitor method(s). The order is:
  67    * Call visitor methods of implemented interfaces first, then
  68    * call methods according to the class hierarchy in descending order,
  69    * i.e., the most specific visitXXX() call comes last.
  70    *
  71    * @param v Visitor object
  72    */
  73   public void accept(Visitor v) {

  74     v.visitExceptionThrower(this);
  75     v.visitStackConsumer(this);
  76     v.visitStackProducer(this);
  77     v.visitTypedInstruction(this);
  78     v.visitLoadClass(this);
  79     v.visitCPInstruction(this);
  80     v.visitFieldOrMethod(this);
  81     v.visitFieldInstruction(this);
  82     v.visitGETFIELD(this);
  83   }
  84 }
   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */

  21 package com.sun.org.apache.bcel.internal.generic;
  22 
  23 import com.sun.org.apache.bcel.internal.Const;
  24 import com.sun.org.apache.bcel.internal.ExceptionConst;

  25 
  26 /**
  27  * GETFIELD - Fetch field from object
  28  * <PRE>Stack: ..., objectref -&gt; ..., value</PRE> OR

  29  * <PRE>Stack: ..., objectref -&gt; ..., value.word1, value.word2</PRE>
  30  *
  31  * @version $Id: GETFIELD.java 1747278 2016-06-07 17:28:43Z britter $
  32  */
  33 public class GETFIELD extends FieldInstruction implements ExceptionThrower, StackConsumer,
  34         StackProducer {
  35 
  36     /**
  37      * Empty constructor needed for the Class.newInstance() statement in
  38      * Instruction.readInstruction(). Not to be used otherwise.
  39      */
  40     GETFIELD() {



  41     }
  42 
  43     public GETFIELD(final int index) {
  44         super(Const.GETFIELD, index);
  45     }









  46 
  47     @Override
  48     public int produceStack(final ConstantPoolGen cpg) {
  49         return getFieldSize(cpg);
  50     }
  51 
  52     @Override
  53     public Class<?>[] getExceptions() {
  54         return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION,
  55                 ExceptionConst.NULL_POINTER_EXCEPTION,
  56                 ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR);
  57     }
  58 
  59     /**
  60      * Call corresponding visitor method(s). The order is: Call visitor methods
  61      * of implemented interfaces first, then call methods according to the class
  62      * hierarchy in descending order, i.e., the most specific visitXXX() call
  63      * comes last.
  64      *
  65      * @param v Visitor object
  66      */
  67     @Override
  68     public void accept(final Visitor v) {
  69         v.visitExceptionThrower(this);
  70         v.visitStackConsumer(this);
  71         v.visitStackProducer(this);
  72         v.visitTypedInstruction(this);
  73         v.visitLoadClass(this);
  74         v.visitCPInstruction(this);
  75         v.visitFieldOrMethod(this);
  76         v.visitFieldInstruction(this);
  77         v.visitGETFIELD(this);
  78     }
  79 }
< prev index next >