1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 import com.sun.org.apache.bcel.internal.ExceptionConstants; 57 64 public class CHECKCAST extends CPInstruction 65 implements LoadClass, ExceptionThrower, StackProducer, StackConsumer { 66 70 CHECKCAST() {} 71 72 75 public CHECKCAST(int index) { 76 super(com.sun.org.apache.bcel.internal.Constants.CHECKCAST, index); 77 } 78 79 81 public Class [] getExceptions() { 82 Class [] cs = new Class [1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length]; 83 84 System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0, 85 cs, 0, ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length); 86 cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = 87 ExceptionConstants.CLASS_CAST_EXCEPTION; 88 return cs; 89 } 90 91 public ObjectType getLoadClassType(ConstantPoolGen cpg) { 92 Type t = getType(cpg); 93 94 if(t instanceof ArrayType) 95 t = ((ArrayType) t).getBasicType(); 96 97 return (t instanceof ObjectType)? (ObjectType) t : null; 98 } 99 100 108 public void accept(Visitor v) { 109 v.visitLoadClass(this); 110 v.visitExceptionThrower(this); 111 v.visitStackProducer(this); 112 v.visitStackConsumer(this); 113 v.visitTypedInstruction(this); 114 v.visitCPInstruction(this); 115 v.visitCHECKCAST(this); 116 } 117 } 118 | Popular Tags |