281 * true if bytecode should be printed out not only when errors 282 * are found. 283 * @param pw 284 * write where results going to be printed 285 */ 286 public static void verify(final ClassReader cr, final boolean dump, 287 final PrintWriter pw) { 288 verify(cr, null, dump, pw); 289 } 290 291 static void printAnalyzerResult(MethodNode method, Analyzer<BasicValue> a, 292 final PrintWriter pw) { 293 Frame<BasicValue>[] frames = a.getFrames(); 294 Textifier t = new Textifier(); 295 TraceMethodVisitor mv = new TraceMethodVisitor(t); 296 297 pw.println(method.name + method.desc); 298 for (int j = 0; j < method.instructions.size(); ++j) { 299 method.instructions.get(j).accept(mv); 300 301 StringBuffer s = new StringBuffer(); 302 Frame<BasicValue> f = frames[j]; 303 if (f == null) { 304 s.append('?'); 305 } else { 306 for (int k = 0; k < f.getLocals(); ++k) { 307 s.append(getShortName(f.getLocal(k).toString())) 308 .append(' '); 309 } 310 s.append(" : "); 311 for (int k = 0; k < f.getStackSize(); ++k) { 312 s.append(getShortName(f.getStack(k).toString())) 313 .append(' '); 314 } 315 } 316 while (s.length() < method.maxStack + method.maxLocals + 1) { 317 s.append(' '); 318 } 319 pw.print(Integer.toString(j + 100000).substring(1)); 320 pw.print(" " + s + " : " + t.text.get(t.text.size() - 1)); 321 } 322 for (int j = 0; j < method.tryCatchBlocks.size(); ++j) { 323 method.tryCatchBlocks.get(j).accept(mv); 324 pw.print(" " + t.text.get(t.text.size() - 1)); 325 } 326 pw.println(); 327 } 328 329 private static String getShortName(final String name) { 330 int n = name.lastIndexOf('/'); 331 int k = name.length(); 332 if (name.charAt(k - 1) == ';') { 333 k--; 334 } 335 return n == -1 ? name : name.substring(n + 1, k); 336 } 337 338 /** 339 * Constructs a new {@link CheckClassAdapter}. <i>Subclasses must not use 340 * this constructor</i>. Instead, they must use the | 281 * true if bytecode should be printed out not only when errors 282 * are found. 283 * @param pw 284 * write where results going to be printed 285 */ 286 public static void verify(final ClassReader cr, final boolean dump, 287 final PrintWriter pw) { 288 verify(cr, null, dump, pw); 289 } 290 291 static void printAnalyzerResult(MethodNode method, Analyzer<BasicValue> a, 292 final PrintWriter pw) { 293 Frame<BasicValue>[] frames = a.getFrames(); 294 Textifier t = new Textifier(); 295 TraceMethodVisitor mv = new TraceMethodVisitor(t); 296 297 pw.println(method.name + method.desc); 298 for (int j = 0; j < method.instructions.size(); ++j) { 299 method.instructions.get(j).accept(mv); 300 301 StringBuilder sb = new StringBuilder(); 302 Frame<BasicValue> f = frames[j]; 303 if (f == null) { 304 sb.append('?'); 305 } else { 306 for (int k = 0; k < f.getLocals(); ++k) { 307 sb.append(getShortName(f.getLocal(k).toString())) 308 .append(' '); 309 } 310 sb.append(" : "); 311 for (int k = 0; k < f.getStackSize(); ++k) { 312 sb.append(getShortName(f.getStack(k).toString())) 313 .append(' '); 314 } 315 } 316 while (sb.length() < method.maxStack + method.maxLocals + 1) { 317 sb.append(' '); 318 } 319 pw.print(Integer.toString(j + 100000).substring(1)); 320 pw.print(" " + sb + " : " + t.text.get(t.text.size() - 1)); 321 } 322 for (int j = 0; j < method.tryCatchBlocks.size(); ++j) { 323 method.tryCatchBlocks.get(j).accept(mv); 324 pw.print(" " + t.text.get(t.text.size() - 1)); 325 } 326 pw.println(); 327 } 328 329 private static String getShortName(final String name) { 330 int n = name.lastIndexOf('/'); 331 int k = name.length(); 332 if (name.charAt(k - 1) == ';') { 333 k--; 334 } 335 return n == -1 ? name : name.substring(n + 1, k); 336 } 337 338 /** 339 * Constructs a new {@link CheckClassAdapter}. <i>Subclasses must not use 340 * this constructor</i>. Instead, they must use the |