1 19 20 25 26 27 package soot; 28 29 import soot.*; 30 import soot.jimple.*; 31 import soot.util.*; 32 import java.util.*; 33 import java.io.*; 34 35 37 public class AbstractTrap implements Trap, Serializable 38 { 39 40 protected transient SootClass exception; 41 42 43 protected UnitBox beginUnitBox; 44 45 46 protected UnitBox endUnitBox; 47 48 49 protected UnitBox handlerUnitBox; 50 51 52 protected List unitBoxes; 53 54 private void readObject( ObjectInputStream in) throws IOException, ClassNotFoundException 55 { 56 in.defaultReadObject(); 57 exception = Scene.v().getSootClass( (String ) in.readObject()); 58 } 59 60 private void writeObject( ObjectOutputStream out) throws IOException 61 { 62 out.defaultWriteObject(); 63 out.writeObject( exception.getName()); 64 } 65 66 67 68 protected AbstractTrap(SootClass exception, UnitBox beginUnitBox, 69 UnitBox endUnitBox, UnitBox handlerUnitBox) 70 { 71 this.exception = exception; this.beginUnitBox = beginUnitBox; 72 this.endUnitBox = endUnitBox; this.handlerUnitBox = handlerUnitBox; 73 74 unitBoxes = new ArrayList(); 75 unitBoxes.add(beginUnitBox); 76 unitBoxes.add(endUnitBox); 77 unitBoxes.add(handlerUnitBox); 78 unitBoxes = Collections.unmodifiableList(unitBoxes); 79 } 80 81 public Unit getBeginUnit() 82 { 83 return beginUnitBox.getUnit(); 84 } 85 86 public Unit getEndUnit() 87 { 88 return endUnitBox.getUnit(); 89 } 90 91 public Unit getHandlerUnit() 92 { 93 return handlerUnitBox.getUnit(); 94 } 95 96 public UnitBox getHandlerUnitBox() 97 { 98 return beginUnitBox; 99 } 100 101 public UnitBox getBeginUnitBox() 102 { 103 return beginUnitBox; 104 } 105 106 public UnitBox getEndUnitBox() 107 { 108 return endUnitBox; 109 } 110 111 public List getUnitBoxes() 112 { 113 return unitBoxes; 114 } 115 116 public void clearUnitBoxes() 117 { 118 Iterator boxesIt = getUnitBoxes().iterator(); 119 while(boxesIt.hasNext()){ 120 UnitBox box = (UnitBox) boxesIt.next(); 121 box.setUnit(null); 122 } 123 } 124 125 public SootClass getException() 126 { 127 return exception; 128 } 129 130 public void setBeginUnit(Unit beginUnit) 131 { 132 beginUnitBox.setUnit(beginUnit); 133 } 134 135 public void setEndUnit(Unit endUnit) 136 { 137 endUnitBox.setUnit(endUnit); 138 } 139 140 public void setHandlerUnit(Unit handlerUnit) 141 { 142 handlerUnitBox.setUnit(handlerUnit); 143 } 144 145 public void setException(SootClass exception) 146 { 147 this.exception = exception; 148 } 149 150 public Object clone() 151 { 152 throw new RuntimeException (); 153 } 154 } 155 | Popular Tags |