1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 import com.sun.org.apache.bcel.internal.ExceptionConstants; 57 58 65 public class ANEWARRAY extends CPInstruction 66 implements LoadClass, AllocationInstruction, ExceptionThrower, StackProducer { 67 71 ANEWARRAY() {} 72 73 public ANEWARRAY(int index) { 74 super(com.sun.org.apache.bcel.internal.Constants.ANEWARRAY, index); 75 } 76 77 public Class [] getExceptions(){ 78 Class [] cs = new Class [1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length]; 79 80 System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0, 81 cs, 0, ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length); 82 cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = 83 ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION; 84 return cs; 85 } 86 87 95 public void accept(Visitor v) { 96 v.visitLoadClass(this); 97 v.visitAllocationInstruction(this); 98 v.visitExceptionThrower(this); 99 v.visitStackProducer(this); 100 v.visitTypedInstruction(this); 101 v.visitCPInstruction(this); 102 v.visitANEWARRAY(this); 103 } 104 105 public ObjectType getLoadClassType(ConstantPoolGen cpg) { 106 Type t = getType(cpg); 107 108 if (t instanceof ArrayType){ 109 t = ((ArrayType) t).getBasicType(); 110 } 111 112 return (t instanceof ObjectType)? (ObjectType) t : null; 113 } 114 } 115 | Popular Tags |