00001 package de.fub.bytecode.generic;
00002
00003 import java.io.*;
00004 import de.fub.bytecode.util.ByteSequence;
00005 import de.fub.bytecode.classfile.ConstantPool;
00006
00007
00008
00009
00010
00011
00012
00013
00014 public class MULTIANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction, ExceptionThrower {
00015 private short dimensions;
00016
00017
00018
00019
00020
00021 MULTIANEWARRAY() {}
00022 public MULTIANEWARRAY(int index, short dimensions) {
00023 super(MULTIANEWARRAY, index);
00024
00025 if(dimensions < 1)
00026 throw new ClassGenException("Invalid dimensions value: " + dimensions);
00027
00028 this.dimensions = dimensions;
00029 length = 4;
00030 }
00031
00032
00033
00034
00035
00036 public int consumeStack(ConstantPoolGen cpg)
00037 { return dimensions; }
00038
00039
00040
00041
00042 public void dump(DataOutputStream out) throws IOException {
00043 out.writeByte(tag);
00044 out.writeShort(index);
00045 out.writeByte(dimensions);
00046 }
00047
00048
00049
00050 public final short getDimensions() { return dimensions; }
00051 public Class[] getExceptions() {
00052 Class[] cs = new Class[2 + EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
00053
00054 System.arraycopy(EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0,
00055 cs, 0, EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
00056 cs[EXCS_CLASS_AND_INTERFACE_RESOLUTION.length-1] = NEGATIVE_ARRAY_SIZE_EXCEPTION;
00057 cs[EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ILLEGAL_ACCESS_ERROR;
00058 return cs;
00059 }
00060
00061
00062
00063 protected void initFromFile(ByteSequence bytes, boolean wide)
00064 throws IOException
00065 {
00066 super.initFromFile(bytes, wide);
00067 dimensions = bytes.readByte();
00068 length = 4;
00069 }
00070
00071
00072
00073 public String toString(ConstantPool cp) {
00074 return super.toString(cp) + " " + dimensions;
00075 }
00076
00077
00078
00079 public String toString(boolean verbose) {
00080 return super.toString(verbose) + " " + index + " " + dimensions;
00081 }
00082 }