00001 package de.fub.bytecode.generic;
00002
00003 import java.io.*;
00004 import de.fub.bytecode.util.ByteSequence;
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 public class NEWARRAY extends Instruction implements AllocationInstruction, ExceptionThrower{
00015 private byte type;
00016
00017
00018
00019
00020
00021 NEWARRAY() {}
00022 public NEWARRAY(byte type) {
00023 super(NEWARRAY, (short)2);
00024 this.type = type;
00025 }
00026
00027
00028
00029
00030 public void dump(DataOutputStream out) throws IOException {
00031 out.writeByte(tag);
00032 out.writeByte(type);
00033 }
00034 public Class[] getExceptions() { return new Class[] { NEGATIVE_ARRAY_SIZE_EXCEPTION }; }
00035
00036
00037
00038 public final Type getType() {
00039 return new ArrayType(BasicType.getType(type), 1);
00040 }
00041
00042
00043
00044 public final byte getTypecode() { return type; }
00045
00046
00047
00048 protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
00049 {
00050 type = bytes.readByte();
00051 length = 2;
00052 }
00053
00054
00055
00056 public String toString(boolean verbose) {
00057 return super.toString(verbose) + " " + TYPE_NAMES[type];
00058 }
00059 }