public static InsnList tryCatchBlock ( TryCatchBlockNode tryCatchBlockNode , Type exceptionType , InsnList tryInsnList , InsnList catchInsnList ) { Validate . notNull ( tryInsnList ) ; // exceptionType can be null Validate . notNull ( catchInsnList ) ; if ( exceptionType != null ) { Validate . isTrue ( exceptionType . getSort ( ) == Type . OBJECT ) ; } InsnList ret = new InsnList ( ) ; LabelNode tryLabelNode = new LabelNode ( ) ; LabelNode catchLabelNode = new LabelNode ( ) ; LabelNode endLabelNode = new LabelNode ( ) ; tryCatchBlockNode . start = tryLabelNode ; tryCatchBlockNode . end = catchLabelNode ; tryCatchBlockNode . handler = catchLabelNode ; tryCatchBlockNode . type = exceptionType == null ? null : exceptionType . getInternalName ( ) ; ret . add ( tryLabelNode ) ; ret . add ( tryInsnList ) ; ret . add ( new JumpInsnNode ( Opcodes . GOTO , endLabelNode ) ) ; ret . add ( catchLabelNode ) ; ret . add ( catchInsnList ) ; ret . add ( endLabelNode ) ; return ret ; }
Generates instructions for a try - catch block .