242 removeLocalVariables(); 243 244 for(int k=0; k < lv.length; k++) { 245 LocalVariable l = lv[k]; 246 InstructionHandle start = il.findHandle(l.getStartPC()); 247 InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength()); 248 249 // Repair malformed handles 250 if(null == start) { 251 start = il.getStart(); 252 } 253 254 if(null == end) { 255 end = il.getEnd(); 256 } 257 258 addLocalVariable(l.getName(), Type.getType(l.getSignature()), 259 l.getIndex(), start, end); 260 } 261 } else if (a instanceof LocalVariableTypeTable) { 262 LocalVariable[] lv = ((LocalVariableTypeTable) a).getLocalVariableTypeTable(); 263 removeLocalVariables(); 264 for (int k = 0; k < lv.length; k++) { 265 LocalVariable l = lv[k]; 266 InstructionHandle start = il.findHandle(l.getStartPC()); 267 InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength()); 268 // Repair malformed handles 269 if (null == start) { 270 start = il.getStart(); 271 } 272 if (null == end) { 273 end = il.getEnd(); 274 } 275 addLocalVariable(l.getName(), Type.getType(l.getSignature()), l 276 .getIndex(), start, end); 277 } 278 } else 279 addCodeAttribute(a); 280 } 281 } else if(a instanceof ExceptionTable) { 282 String[] names = ((ExceptionTable)a).getExceptionNames(); 283 for(int j=0; j < names.length; j++) 284 addException(names[j]); 285 } else 286 addAttribute(a); 287 } 288 } 289 290 /** 291 * Adds a local variable to this method. 292 * 293 * @param name variable name 294 * @param type variable type 295 * @param slot the index of the local variable, if type is long or double, the next available 296 * index is slot+2 297 * @param start from where the variable is valid | 242 removeLocalVariables(); 243 244 for(int k=0; k < lv.length; k++) { 245 LocalVariable l = lv[k]; 246 InstructionHandle start = il.findHandle(l.getStartPC()); 247 InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength()); 248 249 // Repair malformed handles 250 if(null == start) { 251 start = il.getStart(); 252 } 253 254 if(null == end) { 255 end = il.getEnd(); 256 } 257 258 addLocalVariable(l.getName(), Type.getType(l.getSignature()), 259 l.getIndex(), start, end); 260 } 261 } else if (a instanceof LocalVariableTypeTable) { 262 LocalVariable[] oldLV = ((LocalVariableTypeTable) a).getLocalVariableTypeTable(); 263 int lvLength = oldLV.length; 264 LocalVariable[] newLV = new LocalVariable[lvLength]; 265 for (int k = 0; k < lvLength; k++) { 266 LocalVariable l = oldLV[k]; 267 InstructionHandle start = il.findHandle(l.getStartPC()); 268 InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength()); 269 // Repair malformed handles 270 if (null == start) { 271 start = il.getStart(); 272 } 273 if (null == end) { 274 end = il.getEnd(); 275 } 276 LocalVariable newVar = new LocalVariable(l); 277 int startPosition = start.getPosition(); 278 newVar.setStartPC(startPosition); 279 newVar.setLength(end.getPosition() - startPosition); 280 newLV[k] = newVar; 281 } 282 LocalVariableTypeTable newLVTT = new LocalVariableTypeTable( 283 (LocalVariableTypeTable)a); 284 newLVTT.setLocalVariableTable(newLV); 285 addCodeAttribute(newLVTT); 286 } else 287 addCodeAttribute(a); 288 } 289 } else if(a instanceof ExceptionTable) { 290 String[] names = ((ExceptionTable)a).getExceptionNames(); 291 for(int j=0; j < names.length; j++) 292 addException(names[j]); 293 } else 294 addAttribute(a); 295 } 296 } 297 298 /** 299 * Adds a local variable to this method. 300 * 301 * @param name variable name 302 * @param type variable type 303 * @param slot the index of the local variable, if type is long or double, the next available 304 * index is slot+2 305 * @param start from where the variable is valid |