1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Licensed to the Apache Software Foundation (ASF) under one or more 7 * contributor license agreements. See the NOTICE file distributed with 8 * this work for additional information regarding copyright ownership. 9 * The ASF licenses this file to You under the Apache License, Version 2.0 10 * (the "License"); you may not use this file except in compliance with 11 * the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22 package com.sun.org.apache.bcel.internal.generic; 23 24 /** 25 * Thrown by InstructionList.remove() when one or multiple disposed instructions 26 * are still being referenced by an InstructionTargeter object. I.e. the 27 * InstructionTargeter has to be notified that (one of) the InstructionHandle it 28 * is referencing is being removed from the InstructionList and thus not valid anymore. 29 * 30 * <p>Making this an exception instead of a return value forces the user to handle 31 * these case explicitely in a try { ... } catch. The following code illustrates 32 * how this may be done:</p> 33 * 34 * <PRE> 35 * ... 36 * try { 37 * il.delete(start_ih, end_ih); 38 * } catch(TargetLostException e) { 39 * for (InstructionHandle target : e.getTargets()) { 40 * for (InstructionTargeter targeter : target.getTargeters()) { 41 * targeter.updateTarget(target, new_target); 42 * } 43 * } 44 * } 45 * </PRE> 46 * 47 * @see InstructionHandle 48 * @see InstructionList 49 * @see InstructionTargeter 50 * @version $Id$ 51 */ 52 public final class TargetLostException extends Exception { 53 54 private static final long serialVersionUID = -6857272667645328384L; 55 private final InstructionHandle[] targets; 56 57 58 TargetLostException(final InstructionHandle[] t, final String mesg) { 59 super(mesg); 60 targets = t; 61 } 62 63 64 /** 65 * @return list of instructions still being targeted. 66 */ 67 public InstructionHandle[] getTargets() { 68 return targets; 69 } 70 }