00001 package de.fub.bytecode.generic;
00002
00003 import de.fub.bytecode.classfile.ConstantPool;
00004 import de.fub.bytecode.Constants;
00005
00006 import java.io.*;
00007 import de.fub.bytecode.util.ByteSequence;
00008
00009
00010
00011
00012
00013
00014
00015
00016 public final class INVOKEINTERFACE extends InvokeInstruction {
00017 private int nargs;
00018
00019
00020
00021
00022
00023 INVOKEINTERFACE() {}
00024 public INVOKEINTERFACE(int index, int nargs) {
00025 super(Constants.INVOKEINTERFACE, index);
00026 length = 5;
00027
00028 if(nargs < 1)
00029 throw new ClassGenException("Number of arguments must be > 0 " + nargs);
00030
00031 this.nargs = nargs;
00032 }
00033 public int consumeStack(ConstantPoolGen cpg)
00034 { return nargs; }
00035
00036
00037
00038
00039 public void dump(DataOutputStream out) throws IOException {
00040 out.writeByte(tag);
00041 out.writeShort(index);
00042 out.writeByte(nargs);
00043 out.writeByte(0);
00044 }
00045 public Class[] getExceptions(){
00046 Class[] cs = new Class[4 + EXCS_INTERFACE_METHOD_RESOLUTION.length];
00047
00048 System.arraycopy(EXCS_INTERFACE_METHOD_RESOLUTION, 0,
00049 cs, 0, EXCS_INTERFACE_METHOD_RESOLUTION.length);
00050 cs[EXCS_INTERFACE_METHOD_RESOLUTION.length-3] = INCOMPATIBLE_CLASS_CHANGE_ERROR;
00051 cs[EXCS_INTERFACE_METHOD_RESOLUTION.length-2] = ILLEGAL_ACCESS_ERROR;
00052 cs[EXCS_INTERFACE_METHOD_RESOLUTION.length-1] = ABSTRACT_METHOD_ERROR;
00053 cs[EXCS_INTERFACE_METHOD_RESOLUTION.length] = UNSATISFIED_LINK_ERROR;
00054 return cs;
00055 }
00056 public int getNoArguments() { return nargs; }
00057
00058
00059
00060 protected void initFromFile(ByteSequence bytes, boolean wide)
00061 throws IOException
00062 {
00063 super.initFromFile(bytes, wide);
00064
00065 length = 5;
00066 nargs = bytes.readUnsignedByte();
00067 bytes.readByte();
00068 }
00069
00070
00071
00072 public String toString(ConstantPool cp) {
00073 return super.toString(cp) + " " + nargs;
00074 }
00075 }