1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 package org.apache.bcel.generic; 19 20 import java.io.DataOutputStream; 21 import java.io.IOException; 22 23 import org.apache.bcel.Const; 24 import org.apache.bcel.ExceptionConst; 25 26 /** 27 * INVOKESTATIC - Invoke a class (static) method 28 * 29 * <PRE>Stack: ..., [arg1, [arg2 ...]] -> ...</PRE> 30 * 31 * @version $Id$ 32 * @see 33 * <a href="http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokestatic"> 34 * The invokestatic instruction in The Java Virtual Machine Specification</a> 35 */ 36 public class INVOKESTATIC extends InvokeInstruction { 37 38 /** 39 * Empty constructor needed for Instruction.readInstruction. 40 * Not to be used otherwise. 41 */ INVOKESTATIC()42 INVOKESTATIC() { 43 } 44 45 INVOKESTATIC(final int index)46 public INVOKESTATIC(final int index) { 47 super(Const.INVOKESTATIC, index); 48 } 49 50 51 /** 52 * Dump instruction as byte code to stream out. 53 * @param out Output stream 54 */ 55 @Override dump( final DataOutputStream out )56 public void dump( final DataOutputStream out ) throws IOException { 57 out.writeByte(super.getOpcode()); 58 out.writeShort(super.getIndex()); 59 } 60 61 @Override getExceptions()62 public Class<?>[] getExceptions() { 63 return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, 64 ExceptionConst.UNSATISFIED_LINK_ERROR, 65 ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); 66 } 67 68 69 /** 70 * Call corresponding visitor method(s). The order is: 71 * Call visitor methods of implemented interfaces first, then 72 * call methods according to the class hierarchy in descending order, 73 * i.e., the most specific visitXXX() call comes last. 74 * 75 * @param v Visitor object 76 */ 77 @Override accept( final Visitor v )78 public void accept( final Visitor v ) { 79 v.visitExceptionThrower(this); 80 v.visitTypedInstruction(this); 81 v.visitStackConsumer(this); 82 v.visitStackProducer(this); 83 v.visitLoadClass(this); 84 v.visitCPInstruction(this); 85 v.visitFieldOrMethod(this); 86 v.visitInvokeInstruction(this); 87 v.visitINVOKESTATIC(this); 88 } 89 } 90