1 17 package org.apache.bcel.generic; 18 19 import java.io.DataOutputStream ; 20 import java.io.IOException ; 21 import org.apache.bcel.util.ByteSequence; 22 23 31 public class NEWARRAY extends Instruction implements AllocationInstruction, ExceptionThrower, 32 StackProducer { 33 34 private byte type; 35 36 37 41 NEWARRAY() { 42 } 43 44 45 public NEWARRAY(byte type) { 46 super(org.apache.bcel.Constants.NEWARRAY, (short) 2); 47 this.type = type; 48 } 49 50 51 public NEWARRAY(BasicType type) { 52 this(type.getType()); 53 } 54 55 56 60 public void dump( DataOutputStream out ) throws IOException { 61 out.writeByte(opcode); 62 out.writeByte(type); 63 } 64 65 66 69 public final byte getTypecode() { 70 return type; 71 } 72 73 74 77 public final Type getType() { 78 return new ArrayType(BasicType.getType(type), 1); 79 } 80 81 82 85 public String toString( boolean verbose ) { 86 return super.toString(verbose) + " " + org.apache.bcel.Constants.TYPE_NAMES[type]; 87 } 88 89 90 93 protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException { 94 type = bytes.readByte(); 95 length = 2; 96 } 97 98 99 public Class [] getExceptions() { 100 return new Class [] { 101 org.apache.bcel.ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION 102 }; 103 } 104 105 106 114 public void accept( Visitor v ) { 115 v.visitAllocationInstruction(this); 116 v.visitExceptionThrower(this); 117 v.visitStackProducer(this); 118 v.visitNEWARRAY(this); 119 } 120 } 121 | Popular Tags |