1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 import com.sun.org.apache.bcel.internal.classfile.ConstantPool; 57 import com.sun.org.apache.bcel.internal.Constants; 58 import com.sun.org.apache.bcel.internal.ExceptionConstants; 59 60 import java.io.*; 61 import com.sun.org.apache.bcel.internal.util.ByteSequence; 62 63 70 public final class INVOKEINTERFACE extends InvokeInstruction { 71 private int nargs; 73 77 INVOKEINTERFACE() {} 78 79 public INVOKEINTERFACE(int index, int nargs) { 80 super(Constants.INVOKEINTERFACE, index); 81 length = 5; 82 83 if(nargs < 1) 84 throw new ClassGenException("Number of arguments must be > 0 " + nargs); 85 86 this.nargs = nargs; 87 } 88 89 93 public void dump(DataOutputStream out) throws IOException { 94 out.writeByte(opcode); 95 out.writeShort(index); 96 out.writeByte(nargs); 97 out.writeByte(0); 98 } 99 100 104 public int getCount() { return nargs; } 105 106 109 protected void initFromFile(ByteSequence bytes, boolean wide) 110 throws IOException 111 { 112 super.initFromFile(bytes, wide); 113 114 length = 5; 115 nargs = bytes.readUnsignedByte(); 116 bytes.readByte(); } 118 119 122 public String toString(ConstantPool cp) { 123 return super.toString(cp) + " " + nargs; 124 } 125 126 public int consumeStack(ConstantPoolGen cpg) { return nargs; } 129 130 public Class [] getExceptions() { 131 Class [] cs = new Class [4 + ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length]; 132 133 System.arraycopy(ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION, 0, 134 cs, 0, ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length); 135 136 cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length+3] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR; 137 cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length+2] = ExceptionConstants.ILLEGAL_ACCESS_ERROR; 138 cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length+1] = ExceptionConstants.ABSTRACT_METHOD_ERROR; 139 cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length] = ExceptionConstants.UNSATISFIED_LINK_ERROR; 140 141 return cs; 142 } 143 144 152 public void accept(Visitor v) { 153 v.visitExceptionThrower(this); 154 v.visitTypedInstruction(this); 155 v.visitStackConsumer(this); 156 v.visitStackProducer(this); 157 v.visitLoadClass(this); 158 v.visitCPInstruction(this); 159 v.visitFieldOrMethod(this); 160 v.visitInvokeInstruction(this); 161 v.visitINVOKEINTERFACE(this); 162 } 163 } 164 | Popular Tags |