1 17 package org.apache.bcel.generic; 18 19 import org.apache.bcel.ExceptionConstants; 20 21 28 public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThrower, StackProducer, 29 StackConsumer { 30 31 35 CHECKCAST() { 36 } 37 38 39 42 public CHECKCAST(int index) { 43 super(org.apache.bcel.Constants.CHECKCAST, index); 44 } 45 46 47 49 public Class [] getExceptions() { 50 Class [] cs = new Class [1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length]; 51 System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0, cs, 0, 52 ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length); 53 cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.CLASS_CAST_EXCEPTION; 54 return cs; 55 } 56 57 58 public ObjectType getLoadClassType( ConstantPoolGen cpg ) { 59 Type t = getType(cpg); 60 if (t instanceof ArrayType) { 61 t = ((ArrayType) t).getBasicType(); 62 } 63 return (t instanceof ObjectType) ? (ObjectType) t : null; 64 } 65 66 67 75 public void accept( Visitor v ) { 76 v.visitLoadClass(this); 77 v.visitExceptionThrower(this); 78 v.visitStackProducer(this); 79 v.visitStackConsumer(this); 80 v.visitTypedInstruction(this); 81 v.visitCPInstruction(this); 82 v.visitCHECKCAST(this); 83 } 84 } 85 | Popular Tags |