1 package javassist; 2 3 import junit.framework.*; 4 import test1.DefineClassCapability; 5 6 import java.io.File; 7 import java.io.FileInputStream; 8 import java.io.InputStream; 9 import java.lang.reflect.Method; 10 import javassist.bytecode.*; 11 import javassist.expr.*; 12 import javassist.runtime.*; 13 14 @SuppressWarnings({"rawtypes","unused", "resource"}) 15 public class JvstTest extends JvstTestRoot { 16 public static boolean java9; 17 18 static { 19 //javassist.bytecode.MethodInfo.doPreverify = true; 20 java9 = javassist.bytecode.ClassFile.MAJOR_VERSION 21 >= javassist.bytecode.ClassFile.JAVA_9; 22 } JvstTest(String name)23 public JvstTest(String name) { 24 super(name); 25 } 26 testConfig()27 public void testConfig() { 28 // is the value of PATH correct? 29 assertTrue("not found " + PATH, new java.io.File(PATH).exists()); 30 } 31 testLoader()32 public void testLoader() throws Exception { 33 Loader loader = new Loader(sloader); 34 loader.delegateLoadingOf("test1."); 35 assertEquals(loader.loadClass("test1.Cflow").getClassLoader(), 36 loader.getParent()); 37 assertEquals(loader.loadClass("javassist.Loader").getClassLoader(), 38 loader.getParent()); 39 assertEquals(loader.loadClass("javassist.CtClass").getClassLoader(), 40 loader); 41 } 42 testDefreeze()43 public void testDefreeze() throws Exception { 44 CtClass cc = sloader.get("test1.Freeze"); 45 cc.stopPruning(true); 46 cc.addInterface(sloader.get("java.io.Serializable")); 47 assertTrue(!cc.isFrozen()); 48 cc.writeFile(); 49 assertTrue(cc.isFrozen()); 50 cc.defrost(); 51 assertTrue(!cc.isFrozen()); 52 } 53 testClassPath()54 public void testClassPath() throws Exception { 55 ClassPool pool = new ClassPool(null); 56 ClassPath cp1 = pool.appendClassPath("d1"); 57 ClassPath cp2 = pool.appendClassPath("d2"); 58 ClassPath cp3 = pool.appendClassPath("d3"); 59 ClassPath cp4 = pool.appendClassPath("d4"); 60 print(pool.toString()); 61 pool.removeClassPath(cp3); 62 print(pool.toString()); 63 pool.removeClassPath(cp4); 64 print(pool.toString()); 65 pool.removeClassPath(cp2); 66 print(pool.toString()); 67 pool.removeClassPath(cp1); 68 assertTrue("[class path: ]".equals(pool.toString())); 69 } 70 testReleaseJarClassPathFileHandle()71 public void testReleaseJarClassPathFileHandle() throws Exception { 72 String jarFileName = "./empty.jar"; 73 ClassLoader classLoader = getClass().getClassLoader(); 74 File jarFile = new File(classLoader.getResource(jarFileName).getFile()); 75 assertTrue(jarFile.exists()); 76 77 // Prepare class pool and force it to open the Jar file 78 ClassPool pool = ClassPool.getDefault(); 79 ClassPath cp = pool.appendClassPath(jarFile.getAbsolutePath()); 80 assertNull(cp.openClassfile("nothere.Dummy")); 81 82 // Assert that it is possible to delete the jar file. 83 // On Windows deleting an open file will fail, while on on Mac/Linux this is always possible. 84 // This check will thus only fail on Windows if the file is still open. 85 assertTrue(jarFile.delete()); 86 } 87 testJarClassPath()88 public void testJarClassPath() throws Exception { 89 String jarFileName = "./simple.jar"; 90 ClassLoader classLoader = getClass().getClassLoader(); 91 File jarFile = new File(classLoader.getResource(jarFileName).getFile()); 92 assertTrue(jarFile.exists()); 93 94 ClassPool pool = ClassPool.getDefault(); 95 ClassPath cp = pool.appendClassPath(jarFile.getAbsolutePath()); 96 InputStream is = cp.openClassfile("com.test.Test"); 97 assertNotNull(is); 98 is.close(); 99 } 100 testSubtype()101 public void testSubtype() throws Exception { 102 CtClass cc = sloader.get("test1.Subtype"); 103 assertTrue(cc.subtypeOf(cc)); 104 assertTrue(cc.subtypeOf(sloader.get("test1.SubtypeA"))); 105 assertTrue(cc.subtypeOf(sloader.get("test1.SubtypeB"))); 106 assertTrue(cc.subtypeOf(sloader.get("test1.SubtypeC"))); 107 assertTrue(cc.subtypeOf(sloader.get("java.lang.Object"))); 108 assertTrue(!cc.subtypeOf(sloader.get("java.lang.String"))); 109 } 110 testClassPoolGet()111 public void testClassPoolGet() throws Exception { 112 ClassPool pool = ClassPool.getDefault(); 113 CtClass cc = pool.makeClass("test1.Point"); 114 CtClass cc1 = pool.get("test1.Point"); // cc1 is identical to cc. 115 cc.setName("test1.Pair"); 116 CtClass cc2 = pool.get("test1.Pair"); // cc2 is identical to cc. 117 CtClass cc3 = pool.get("test1.Point"); // cc3 is not identical to cc. 118 119 assertTrue(cc == cc1); 120 assertTrue(cc == cc2); 121 assertTrue(cc != cc3); 122 123 assertEquals("test1.Pair", cc.getName()); 124 assertEquals("test1.Point", cc3.getName()); 125 } 126 127 public static long testFieldInitHash; 128 129 /* test CodeIterator.insertExGap(). 130 * The result of this test is checked again by JvstTest3#testFieldInitAgain(). 131 */ testFieldInit()132 public void testFieldInit() throws Exception { 133 CtClass cc = sloader.get("test1.FieldInit"); 134 CtField f1 = new CtField(CtClass.intType, "f1", cc); 135 cc.addField(f1, CtField.Initializer.byCall(cc, "get")); 136 CtField f2 = CtField.make("public int f2 = 3;", cc); 137 cc.addField(f2); 138 CtField f3 = CtField.make("public int f3;", cc); 139 cc.addField(f3); 140 CtField f4 = CtField.make("public int f4 = this.f2 + 3;", cc); 141 cc.addField(f4); 142 CtField fi = CtField.make("public test1.FieldInit.FI fi = new test1.FieldInit.FI(this);", cc); 143 cc.addField(fi); 144 testFieldInitHash = f1.hashCode(); 145 cc.writeFile(); 146 Object obj = make(cc.getName()); 147 int value = obj.getClass().getField("counter").getInt(obj); 148 assertEquals(1, value); 149 int value2 = obj.getClass().getField("f2").getInt(obj); 150 assertEquals(3, value2); 151 int value3 = obj.getClass().getField("f3").getInt(obj); 152 assertEquals(0, value3); 153 int value4 = obj.getClass().getField("f4").getInt(obj); 154 assertEquals(6, value4); 155 Object obfi = obj.getClass().getField("fi").get(obj); 156 assertTrue(obfi.getClass().getField("fi").get(obfi) == obj); 157 } 158 159 /* test CodeIterator.insertExGap(). 160 */ testFieldInit2()161 public void testFieldInit2() throws Exception { 162 CtClass cc = sloader.get("test1.FieldInit2"); 163 CtField f = new CtField(CtClass.intType, "f1", cc); 164 cc.addField(f, CtField.Initializer.byCall(cc, "get")); 165 cc.writeFile(); 166 try { 167 Object obj = make(cc.getName()); 168 fail(); 169 } 170 catch (Exception e) { 171 print("testFieldInit2: catch"); 172 } 173 } 174 175 public static CtMethod testCalleeBeforeMethod; 176 public static long testCalleeBeforeMethod2; 177 178 /* The test result is checked again by JvstTest3#testCalleeBeforeAgain(). 179 */ testCalleeBefore()180 public void testCalleeBefore() throws Exception { 181 CtClass cc = sloader.get("test1.CalleeBefore"); 182 183 CtMethod m1 = cc.getDeclaredMethod("m1"); 184 m1.insertBefore("{ int k = 1; p = k; }"); 185 CtMethod m2 = cc.getDeclaredMethod("m2"); 186 testCalleeBeforeMethod = m1; 187 testCalleeBeforeMethod2 = m2.getMethodInfo2().hashCode(); 188 m2.insertBefore("{ int k = 3; q = k; }"); 189 CtConstructor[] cons = cc.getDeclaredConstructors(); 190 191 for (int i = 0; i < cons.length; ++i) { 192 MethodInfo minfo = cons[i].getMethodInfo(); 193 CodeAttribute ca = minfo.getCodeAttribute(); 194 CodeIterator iterator = ca.iterator(); 195 if (cons[i].getParameterTypes().length == 0) { 196 assertTrue(iterator.skipThisConstructor() >= 0); 197 assertTrue(iterator.skipSuperConstructor() < 0); 198 assertTrue(iterator.skipConstructor() >= 0); 199 } 200 else { 201 assertTrue(iterator.skipThisConstructor() < 0); 202 assertTrue(iterator.skipSuperConstructor() >= 0); 203 assertTrue(iterator.skipConstructor() >= 0); 204 } 205 206 cons[i].insertBeforeBody("{ int k = 1; counter += k; }"); 207 } 208 209 cc.writeFile(); 210 Object obj = make(cc.getName()); 211 assertEquals(0, invoke(obj, "getr")); 212 assertEquals(17, invoke(obj, "test")); 213 } 214 testCalleeAfter()215 public void testCalleeAfter() throws Exception { 216 CtClass cc = sloader.get("test1.CalleeAfter"); 217 218 CtMethod m1 = cc.getDeclaredMethod("m1"); 219 m1.insertAfter("{ int k = 1; $_ = $_ + k; }", false); 220 221 CtMethod m2 = cc.getDeclaredMethod("m2"); 222 m2.insertAfter("{ char k = 1; $_ = $_ + k; }", false); 223 224 CtConstructor[] cons = cc.getDeclaredConstructors(); 225 cons[0].insertAfter("{ ++p; $_ = ($r)null; }", false); 226 227 cc.writeFile(); 228 Object obj = make(cc.getName()); 229 assertEquals(15, invoke(obj, "test")); 230 } 231 testCalleeAfter2()232 public void testCalleeAfter2() throws Exception { 233 CtClass cc = sloader.get("test1.CalleeAfter2"); 234 235 CtMethod m1 = cc.getDeclaredMethod("m1"); 236 m1.insertAfter("$_ = 7; $_ = ($r)k1(0);", false); 237 238 CtMethod m2 = cc.getDeclaredMethod("m2"); 239 m2.insertAfter("$_ = ($r)k2(0);", false); 240 241 CtMethod m3 = cc.getDeclaredMethod("m3"); 242 m3.insertAfter("$_ = ($r)k3(0);", false); 243 244 CtMethod m4 = cc.getDeclaredMethod("m4"); 245 try { 246 m4.insertAfter("$_ = ($r)1;", false); 247 assertTrue(false); 248 } 249 catch (CannotCompileException e) { 250 } 251 252 CtMethod m5 = cc.getDeclaredMethod("m5"); 253 m5.insertAfter("$_ = ($r)k5(0);", false); 254 255 cc.writeFile(); 256 Object obj = make(cc.getName()); 257 assertEquals(17, invoke(obj, "test")); 258 } 259 testCalleeAfter3()260 public void testCalleeAfter3() throws Exception { 261 CtClass cc = sloader.get("test1.CalleeAfter3"); 262 CtMethod m1 = cc.getDeclaredMethod("m1"); 263 m1.insertAfter("value++;", true); 264 CtMethod m2 = cc.getDeclaredMethod("m2"); 265 m2.insertAfter("value++;", true); 266 CtMethod m3 = cc.getDeclaredMethod("m3"); 267 m3.insertAfter("value++;", true); 268 CtMethod m4 = cc.getDeclaredMethod("m4"); 269 m4.insertAfter("value++;", true); 270 cc.writeFile(); 271 Object obj = make(cc.getName()); 272 assertEquals(22, invoke(obj, "test")); 273 } 274 testCalleeCatch()275 public void testCalleeCatch() throws Exception { 276 CtClass cc = sloader.get("test1.CalleeCatch"); 277 278 CtMethod m1 = cc.getDeclaredMethod("m1"); 279 m1.addCatch("{ System.out.println($e); return p; }", 280 sloader.get("java.lang.Exception")); 281 282 cc.writeFile(); 283 Object obj = make(cc.getName()); 284 assertEquals(3, invoke(obj, "test")); 285 } 286 testSuperclass()287 public void testSuperclass() throws Exception { 288 CtClass cc = sloader.get("java.lang.Object"); 289 assertEquals(null, cc.getSuperclass()); 290 } 291 testProceed()292 public void testProceed() throws Exception { 293 CtClass cc = sloader.get("test1.Proceed"); 294 295 CtMethod m1 = CtNewMethod.make( 296 "public int m1() { return $proceed(3); }", 297 cc, "this", "k1"); 298 CtMethod m2 = CtNewMethod.make( 299 "public int m2() { return $proceed(3); }", 300 cc, "another", "k2"); 301 CtMethod m3 = CtNewMethod.make( 302 "public int q(int i) { return p($1 + 1, $$); }", cc); 303 cc.addMethod(m1); 304 cc.addMethod(m2); 305 cc.addMethod(m3); 306 CtMethod m4 = CtNewMethod.make( 307 "public int q2() { return q(4); }", cc); 308 cc.addMethod(m4); 309 310 cc.writeFile(); 311 Object obj = make(cc.getName()); 312 assertEquals(3, invoke(obj, "m1")); 313 assertEquals(4, invoke(obj, "m2")); 314 assertEquals(9, invoke(obj, "q2")); 315 } 316 testProceed2()317 public void testProceed2() throws Exception { 318 CtClass cc = sloader.get("test1.Proceed2"); 319 CtMethod m1 = cc.getDeclaredMethod("k1"); 320 m1.instrument(new ExprEditor() { 321 public void edit(MethodCall m) throws CannotCompileException { 322 m.replace("{ $_ = $proceed($$); }"); 323 } 324 public void edit(NewExpr m) throws CannotCompileException { 325 m.replace("{ $_ = $proceed($$); }"); 326 } 327 public void edit(FieldAccess m) throws CannotCompileException { 328 m.replace("{ $_ = $proceed($$); }"); 329 } 330 public void edit(Instanceof i) throws CannotCompileException { 331 i.replace("{ $_ = $proceed($$); }"); 332 } 333 public void edit(Cast c) throws CannotCompileException { 334 c.replace("{ $_ = $proceed($$); }"); 335 } 336 }); 337 338 CtMethod m2 = cc.getDeclaredMethod("k2"); 339 m2.instrument(new ExprEditor() { 340 public void edit(MethodCall m) throws CannotCompileException { 341 m.replace("{ $proceed(); }"); 342 } 343 public void edit(NewExpr m) throws CannotCompileException { 344 m.replace("{ $_ = $proceed(); }"); 345 } 346 public void edit(FieldAccess m) throws CannotCompileException { 347 if (m.isReader()) 348 m.replace("{ $_ = $proceed(); }"); 349 else 350 m.replace("{ $proceed($$); }"); 351 } 352 }); 353 354 cc.writeFile(); 355 Object obj = make(cc.getName()); 356 assertEquals(2, invoke(obj, "k1")); 357 } 358 testProceed3()359 public void testProceed3() throws Exception { 360 CtClass cc = sloader.get("test1.Proceed3"); 361 CtMethod m1 = cc.getDeclaredMethod("p"); 362 CtMethod m2 = CtNewMethod.copy(m1, cc, null); 363 m1.setName(m1.getName() + "_orig"); 364 m2.setBody("{ return $proceed($1 + 1); }", "this", m1.getName()); 365 cc.addMethod(m2); 366 cc.writeFile(); 367 Object obj = make(cc.getName()); 368 assertEquals(4, invoke(obj, "k1")); 369 } 370 testSetBody()371 public void testSetBody() throws Exception { 372 CtClass cc = sloader.get("test1.SetBody"); 373 CtMethod m1 = cc.getDeclaredMethod("m1"); 374 m1.setBody("{ int i = $1 * $2; return i; }"); 375 CtMethod m2 = cc.getDeclaredMethod("m2"); 376 m2.setBody("System.out.println(\"setbody: \" + $1);"); 377 378 CtMethod m3 = cc.getDeclaredMethod("m3"); 379 try { 380 m3.setBody("value = 1; System.out.println(\"setbody: \" + $1);"); 381 fail(); 382 } 383 catch (CannotCompileException e) { 384 // System.err.println(e); 385 } 386 387 CtConstructor cons 388 = new CtConstructor(new CtClass[] { CtClass.intType }, cc); 389 cons.setBody(null); 390 cc.addConstructor(cons); 391 392 cc.writeFile(); 393 Object obj = make(cc.getName()); 394 assertEquals(12, invoke(obj, "run")); 395 } 396 testSetStaticConsBody()397 public void testSetStaticConsBody() throws Exception { 398 CtClass cc = sloader.get("test1.StaticConsBody"); 399 CtConstructor cons = cc.getClassInitializer(); 400 cons.setBody(null); 401 402 cons = cc.getConstructors()[0]; 403 cons.setBody(null); 404 405 cc.writeFile(); 406 Object obj = make(cc.getName()); 407 assertEquals(0, invoke(obj, "run")); 408 } 409 testSetConsBody()410 public void testSetConsBody() throws Exception { 411 CtClass superClazz = sloader.get("java.io.File"); 412 CtClass cc = sloader.makeClass("test1.SetConsBody"); 413 cc.setSuperclass(superClazz); 414 CtConstructor constructor = new CtConstructor(new CtClass[0], cc); 415 constructor.setBody("super(\"MyFile\");"); 416 cc.addConstructor(constructor); 417 418 constructor = new CtConstructor(new CtClass[] { CtClass.intType }, 419 cc); 420 constructor.setBody("{ super(\"MyFile\"); }"); 421 cc.addConstructor(constructor); 422 423 cc.addMethod(CtNewMethod.make(CtClass.voidType, "m1", 424 null, null, null, cc)); 425 cc.addMethod(CtNewMethod.make(CtClass.intType, "m2", 426 null, null, null, cc)); 427 cc.addMethod(CtNewMethod.make(CtClass.byteType, "m3", 428 null, null, null, cc)); 429 cc.addMethod(CtNewMethod.make(CtClass.longType, "m4", 430 null, null, null, cc)); 431 cc.addMethod(CtNewMethod.make(CtClass.floatType, "m5", 432 null, null, null, cc)); 433 cc.addMethod(CtNewMethod.make(CtClass.doubleType, "m6", 434 null, null, null, cc)); 435 cc.addMethod(CtNewMethod.make(sloader.get("int[]"), "m7", 436 null, null, null, cc)); 437 438 cc.addMethod(CtNewMethod.make( 439 "public int run() {" 440 + " return (int)(m2() + m3() + m4() + m5() + m6() + 3); }", cc)); 441 cc.writeFile(); 442 Object obj = make(cc.getName()); 443 assertEquals(3, invoke(obj, "run")); 444 } 445 testEmptyBody()446 public void testEmptyBody() throws Exception { 447 String[] methods = { "m1", "m2", "m3", "m4" }; 448 boolean[] results = { true, false, false, false, true }; 449 boolean[] cResults = { true, true, false, false, false, true }; 450 451 CtClass cc = sloader.get("test1.EmptyBody"); 452 for (int i = 0; i < methods.length; ++i) { 453 CtMethod m = cc.getDeclaredMethod(methods[i]); 454 assertEquals(results[i], m.isEmpty()); 455 } 456 457 CtConstructor[] cons = cc.getDeclaredConstructors(); 458 for (int j = 0; j < cons.length; ++j) 459 assertEquals(cResults[j], cons[j].isEmpty()); 460 } 461 testExprEditor()462 public void testExprEditor() throws Exception { 463 CtClass cc = sloader.get("test1.ExprEdit"); 464 465 CtMethod m1 = cc.getDeclaredMethod("k0"); 466 m1.instrument(new ExprEditor() { 467 public void edit(MethodCall m) throws CannotCompileException { 468 if (m.getClassName().equals("test1.ExprEdit")) { 469 String name = m.getMethodName(); 470 if (name.equals("k1") || name.equals("k2")) { 471 try { 472 CtMethod cm = m.getMethod(); 473 print(cm.getParameterTypes()[0].getName()); 474 print(cm.getReturnType().getName()); 475 } 476 catch (NotFoundException e) { 477 throw new CannotCompileException(e); 478 } 479 m.replace("{ ++$1; $_ = $proceed($$); }"); 480 } 481 else if (name.equals("k3")) 482 m.replace("{ ++$1; $proceed($$); }"); 483 } 484 } 485 }); 486 487 cc.writeFile(); 488 Object obj = make(cc.getName()); 489 assertEquals(12, invoke(obj, "k0")); 490 } 491 testExprEditor2()492 public void testExprEditor2() throws Exception { 493 CtClass cc = sloader.get("test1.ExprEdit2"); 494 495 CtMethod m1 = cc.getDeclaredMethod("k1"); 496 m1.instrument(new ExprEditor() { 497 public void edit(FieldAccess m) throws CannotCompileException { 498 if (m.getClassName().equals("test1.ExprEdit2")) { 499 String name = m.getFieldName(); 500 try { 501 CtField cf = m.getField(); 502 print(cf.getType().getName()); 503 print("file: " + m.getFileName()); 504 print("line: " + m.getLineNumber()); 505 } 506 catch (NotFoundException e) { 507 throw new CannotCompileException(e); 508 } 509 if (name.equals("df")) 510 if (m.isReader()) 511 m.replace("{ $_ = $proceed() + 1; }"); 512 else 513 m.replace("{ $proceed($1 + 1); }"); 514 else if (name.equals("sf")) 515 if (m.isReader()) 516 m.replace("{ $_ = $proceed() + 2; }"); 517 else 518 m.replace("{ $proceed($1 + 2); }"); 519 } 520 } 521 }); 522 523 cc.writeFile(); 524 Object obj = make(cc.getName()); 525 assertEquals(16, invoke(obj, "k1")); 526 } 527 testExprEditor3()528 public void testExprEditor3() throws Exception { 529 CtClass cc = sloader.get("test1.ExprEdit3"); 530 531 CtMethod m1 = cc.getDeclaredMethod("k1"); 532 m1.instrument(new ExprEditor() { 533 public void edit(NewExpr m) throws CannotCompileException { 534 System.out.println("new " + m.getClassName()); 535 try { 536 CtConstructor cc = m.getConstructor(); 537 print(cc.getParameterTypes()[0].getName()); 538 } 539 catch (NotFoundException e) { 540 throw new CannotCompileException(e); 541 } 542 if (m.getClassName().equals("test1.ExprEdit3")) { 543 m.replace("{ ++$2; $_ = $proceed($$); }"); 544 } 545 } 546 }); 547 548 cc.writeFile(); 549 Object obj = make(cc.getName()); 550 assertEquals(4, invoke(obj, "k1")); 551 } 552 testExprEditor4()553 public void testExprEditor4() throws Exception { 554 CtClass cc = sloader.get("test1.ExprEdit4"); 555 556 CtMethod m1 = cc.getDeclaredMethod("k1"); 557 m1.instrument(new ExprEditor() { 558 public void edit(NewExpr m) throws CannotCompileException { 559 System.out.println("new " + m.getClassName()); 560 if (m.getClassName().equals("test1.ExprEdit4")) 561 m.replace("$_ = null;"); 562 } 563 564 public void edit(MethodCall m) throws CannotCompileException { 565 if (m.getClassName().equals("test1.ExprEdit4")) 566 m.replace("{}"); 567 } 568 }); 569 570 cc.writeFile(); 571 Object obj = make(cc.getName()); 572 assertEquals(1, invoke(obj, "k1")); 573 } 574 testExprEditor5()575 public void testExprEditor5() throws Exception { 576 CtClass cc = sloader.get("test1.ExprEdit5"); 577 578 CtMethod m1 = cc.getDeclaredMethod("k1"); 579 m1.instrument(new ExprEditor() { 580 public void edit(NewExpr m) throws CannotCompileException { 581 m.replace("{ $_ = $proceed($$, \"test\"); }"); 582 } 583 }); 584 585 cc.writeFile(); 586 Object obj = make(cc.getName()); 587 assertEquals(1, invoke(obj, "k1")); 588 } 589 testExprEditor6()590 public void testExprEditor6() throws Exception { 591 CtClass cc = sloader.get("test1.ExprEdit6"); 592 cc.instrument(new ExprEditor() { 593 public void edit(MethodCall m) throws CannotCompileException { 594 assertTrue(m.where().getName().equals("k1")); 595 m.replace("$_ = 3;"); 596 } 597 }); 598 599 cc.writeFile(); 600 Object obj = make(cc.getName()); 601 assertEquals(3, invoke(obj, "k1")); 602 } 603 testExprEditor7()604 public void testExprEditor7() throws Exception { 605 CtClass cc = sloader.get("test1.ExprEdit7"); 606 cc.instrument(new ExprEditor() { 607 public void edit(Instanceof i) throws CannotCompileException { 608 i.replace("{ this.c1 = $type; $_ = !$proceed($1); }"); 609 } 610 public void edit(Cast c) throws CannotCompileException { 611 c.replace("{ this.c2 = $type; $_ = ($r)$1; }"); 612 } 613 }); 614 615 cc.writeFile(); 616 Object obj = make(cc.getName()); 617 assertEquals(7, invoke(obj, "k1")); 618 } 619 testExprEditor8()620 public void testExprEditor8() throws Exception { 621 CtClass cc = sloader.get("test1.ExprEdit8"); 622 cc.instrument(new ExprEditor() { 623 public void edit(ConstructorCall c) throws CannotCompileException { 624 assertTrue(c.isSuper()); 625 c.replace("{ $_ = $proceed($$); value = 7; }"); 626 } 627 }); 628 629 cc.writeFile(); 630 Object obj = make(cc.getName()); 631 assertEquals(7, invoke(obj, "k1")); 632 } 633 testCflow()634 public void testCflow() throws Exception { 635 CtClass cc = sloader.get("test1.Cflow"); 636 CtMethod m1 = cc.getDeclaredMethod("k1"); 637 m1.useCflow("cflow1"); 638 m1.insertBefore("System.out.println(\"$cflow1: \" + $cflow(cflow1));"); 639 m1.insertAfter("System.out.println(\"*$cflow1: \" + $cflow(cflow1));", 640 true); 641 CtMethod m2 = cc.getDeclaredMethod("k2"); 642 m2.useCflow("test1.t.cflow2"); 643 m2.insertBefore( 644 "System.out.println(\"$cflow2: \" + $cflow(test1.t.cflow2));"); 645 CtMethod m3 = cc.getDeclaredMethod("fact"); 646 m3.useCflow("fact"); 647 m3.insertBefore("if ($cflow(fact) == 0)" 648 + " System.out.println(\"fact \" + $1);"); 649 650 cc.writeFile(); 651 Object obj = make(cc.getName()); 652 assertEquals(1, invoke(obj, "run")); 653 assertEquals(120, invoke(obj, "run2")); 654 } 655 testSigType()656 public void testSigType() throws Exception { 657 CtClass cc = sloader.get("test1.SigType"); 658 659 CtMethod m1 = cc.getDeclaredMethod("k1"); 660 m1.insertBefore("{ Class[] p = $sig; $1 += p.length; }"); 661 m1.insertAfter("System.out.println(\"testSigType: \"" 662 + " + $type.getName());", false); 663 664 CtMethod m2 = cc.getDeclaredMethod("k2"); 665 m2.instrument(new ExprEditor() { 666 public void edit(FieldAccess m) throws CannotCompileException { 667 m.replace("{ $_ = $proceed($$) + $type.getName().length(); }"); 668 } 669 670 public void edit(MethodCall m) throws CannotCompileException { 671 m.replace("{ $_ = $proceed($$) + $sig.length; }"); 672 } 673 }); 674 675 cc.writeFile(); 676 Object obj = make(cc.getName()); 677 assertEquals(19, invoke(obj, "run")); 678 } 679 testDollarClass()680 public void testDollarClass() throws Exception { 681 CtClass cc = sloader.get("test1.DollarClass"); 682 683 CtMethod m1 = cc.getDeclaredMethod("k1"); 684 m1.insertBefore("{ $1 += $class.getName().length(); }"); 685 686 CtMethod m2 = cc.getDeclaredMethod("k2"); 687 m2.instrument(new ExprEditor() { 688 public void edit(MethodCall m) throws CannotCompileException { 689 m.replace("{ $_ = $class.getName().length(); }"); 690 } 691 }); 692 m2.insertBefore("{ $1 += $class.getName().length(); }"); 693 694 cc.writeFile(); 695 Object obj = make(cc.getName()); 696 assertEquals(58, invoke(obj, "run")); 697 } 698 testHandler()699 public void testHandler() throws Exception { 700 CtClass cc = sloader.get("test1.Handler"); 701 702 CtMethod m1 = cc.getDeclaredMethod("m1"); 703 m1.instrument(new ExprEditor() { 704 public void edit(Handler h) throws CannotCompileException { 705 try { 706 print(h.getType().getName()); 707 h.insertBefore( 708 "{ p = (($r)$1).getClass().getName().length()" 709 + "+ $type.getName().length(); }"); 710 } 711 catch (NotFoundException e) { 712 throw new CannotCompileException(e); 713 } 714 } 715 }); 716 717 cc.writeFile(); 718 Object obj = make(cc.getName()); 719 assertEquals(("java.lang.IndexOutOfBoundsException".length() 720 + "java.lang.ClassNotFoundException".length()) 721 * 2 + 1, 722 invoke(obj, "test")); 723 } 724 testInterface()725 public void testInterface() throws Exception { 726 String className = "test1.NewInterface"; 727 ClassPool pool = ClassPool.getDefault(); 728 CtClass targetCtClass = pool.get(className); 729 CtClass ctInterface 730 = pool.makeInterface(className + "2"); 731 CtMethod[] ctMethods = targetCtClass.getDeclaredMethods(); 732 for (int i = 0;i < ctMethods.length; i++) { 733 String code = Modifier.toString(ctMethods[i].getModifiers()) 734 + " " + ctMethods[i].getReturnType().getName() 735 + " " + ctMethods[i].getName() + "();"; 736 737 System.out.println(code); 738 CtMethod m = CtNewMethod.make(code, ctInterface); 739 ctInterface.addMethod(m); 740 } 741 742 targetCtClass.addInterface(ctInterface); 743 targetCtClass.stopPruning(true); 744 targetCtClass.writeFile(); 745 746 ctInterface.stopPruning(true); 747 ctInterface.writeFile(); 748 ctInterface.toClass(DefineClassCapability.class); 749 targetCtClass.toClass(DefineClassCapability.class); 750 } 751 testDispatch()752 public void testDispatch() throws Exception { 753 CtClass cc = sloader.get("test1.Dispatch"); 754 755 CtMethod m1 = cc.getDeclaredMethod("run"); 756 m1.insertAfter("$_ += f(new Object[1]);"); 757 cc.writeFile(); 758 Object obj = make(cc.getName()); 759 assertEquals(7, invoke(obj, "run")); 760 } 761 testMakeClass()762 public void testMakeClass()throws Exception { 763 CtClass cc = sloader.makeClass( 764 new FileInputStream(PATH + "test1/MakeClass.class")); 765 assertEquals("test1.MakeClass", cc.getName()); 766 assertEquals(cc, sloader.get(cc.getName())); 767 cc.toBytecode(); 768 assertTrue(cc.isFrozen()); 769 try { 770 cc = sloader.makeClass( 771 new FileInputStream(PATH + "test1/MakeClass.class")); 772 assertTrue(false); 773 } 774 catch (RuntimeException e) { 775 print(e.getMessage()); 776 } 777 } 778 testMakeMethod()779 public void testMakeMethod() throws Exception { 780 CtClass cc = sloader.makeClass("test1.MakeMethod"); 781 cc.addField(new CtField(CtClass.intType, "i", cc)); 782 String cons_body = "{ i = 3; }"; 783 CtConstructor cons = CtNewConstructor.make(null, null, 784 cons_body, cc); 785 cc.addConstructor(cons); 786 CtMethod m = CtNewMethod.make(CtClass.intType, "run", null, null, 787 "{ return i; }", cc); 788 cc.addMethod(m); 789 cc.writeFile(); 790 Object obj = make(cc.getName()); 791 assertEquals(3, invoke(obj, "run")); 792 } 793 testDesc()794 public void testDesc() throws Exception { 795 Class[] sig; 796 797 assertEquals(int.class, Desc.getType("I")); 798 assertEquals(String.class, Desc.getType("Ljava/lang/String;")); 799 assertEquals(String[].class, Desc.getType("[Ljava/lang/String;")); 800 assertEquals(int[].class, Desc.getType("[I")); 801 802 sig = Desc.getParams("()V"); 803 assertEquals(0, sig.length); 804 805 sig = Desc.getParams("(I)V"); 806 assertEquals(int.class, sig[0]); 807 assertEquals(1, sig.length); 808 809 sig = Desc.getParams("(IJ)V"); 810 assertEquals(long.class, sig[1]); 811 assertEquals(2, sig.length); 812 813 sig = Desc.getParams("(Ljava/lang/String;)V"); 814 assertEquals(String.class, sig[0]); 815 assertEquals(1, sig.length); 816 817 sig = Desc.getParams("([Ljava/lang/String;I)V"); 818 assertEquals(String[].class, sig[0]); 819 assertEquals(2, sig.length); 820 821 sig = Desc.getParams("(Ljava/lang/String;[Ljava/lang/String;)V"); 822 assertEquals(String[].class, sig[1]); 823 assertEquals(2, sig.length); 824 } 825 testCast()826 public void testCast() throws Exception { 827 CtClass cc = sloader.makeClass("test1.CastTest"); 828 829 StringBuffer src = new StringBuffer(); 830 src.append("public void test(java.lang.String[] strValues)\n"); 831 src.append("{\n"); 832 src.append("\tObject[] values = new Object[2];"); 833 src.append("\tvalues[0] = strValues;"); 834 src.append("\tvalues[1] = strValues;"); 835 src.append("\tstrValues = (String[])values[0];"); 836 src.append("}\n"); 837 838 CtMethod m = CtNewMethod.make(src.toString(), cc); 839 } 840 841 static final long svUID = 6006955401253799668L; 842 testSerialVUID()843 public void testSerialVUID() throws Exception { 844 CtClass cc = sloader.get("test1.MySerializableClass"); 845 assertEquals(svUID, SerialVersionUID.calculateDefault(cc)); 846 SerialVersionUID.setSerialVersionUID(cc); 847 cc.writeFile(); 848 } 849 testInvokeInt()850 public void testInvokeInt() throws Exception { 851 CtClass cc = sloader.get("test1.InvokeInt"); 852 CtMethod m1 = cc.getDeclaredMethod("check"); 853 854 m1.instrument(new ExprEditor() { 855 public void edit(MethodCall m) throws CannotCompileException { 856 m.replace("$_ = $proceed($$) + k(1);"); 857 } 858 }); 859 860 cc.writeFile(); 861 Object obj = make(cc.getName()); 862 assertEquals(6, invoke(obj, "run")); 863 } 864 testSubtypeOf()865 public void testSubtypeOf() throws Exception { 866 testSubtypeOf2("java.lang.Object", "int", false); 867 testSubtypeOf2("int[]", "java.lang.Object", true); 868 testSubtypeOf2("int[]", "java.lang.Cloneable", true); 869 testSubtypeOf2("java.lang.Object", "int[]", false); 870 testSubtypeOf2("java.lang.Integer", "java.lang.Number", true); 871 testSubtypeOf2("java.lang.Number", "java.lang.Integer", false); 872 testSubtypeOf2("java.lang.Integer[]", "java.lang.Number[]", true); 873 testSubtypeOf2("java.lang.Number[]", "java.lang.Integer[]", false); 874 testSubtypeOf2("java.lang.Integer", "java.io.Serializable", true); 875 testSubtypeOf2("java.lang.Integer", "java.lang.Object", true); 876 } 877 testSubtypeOf2(String s, String t, boolean b)878 private void testSubtypeOf2(String s, String t, boolean b) 879 throws Exception 880 { 881 assertTrue(sloader.get(s).subtypeOf(sloader.get(t)) == b); 882 } 883 testMakeInterface()884 public void testMakeInterface() throws Exception { 885 CtClass cc = sloader.makeInterface("test1.MkInterface"); 886 CtMethod m = CtNewMethod.make("public abstract void ready();", cc); 887 cc.addMethod(m); 888 cc.writeFile(); 889 // cloader.loadClass(cc.getName()); 890 java.io.File genDir = new java.io.File("."); 891 java.net.URLClassLoader ucl = new java.net.URLClassLoader( 892 new java.net.URL[] { genDir.toURI().toURL() }, null); 893 Class intf = ucl.loadClass("test1.MkInterface"); 894 } 895 testCodeConv()896 public void testCodeConv() throws Exception { 897 CtClass cc = sloader.get("test1.CodeConv"); 898 CtClass pc = sloader.get("test1.CodeConvP"); 899 900 CodeConverter conv = new CodeConverter(); 901 conv.replaceFieldRead(pc.getDeclaredField("a1"), cc, "getA1"); 902 conv.replaceFieldRead(pc.getDeclaredField("a2"), cc, "getA2"); 903 conv.redirectFieldAccess(pc.getDeclaredField("a3"), cc, "a4"); 904 conv.replaceFieldWrite(pc.getDeclaredField("b1"), cc, "putB1"); 905 906 cc.instrument(conv); 907 cc.writeFile(); 908 Object obj = make(cc.getName()); 909 assertEquals(51, invoke(obj, "run")); 910 } 911 testTryCatch()912 public void testTryCatch() throws Exception { 913 CtClass cc = sloader.get("test1.TryCatch"); 914 CtMethod m1 = cc.getDeclaredMethod("m1"); 915 916 m1.instrument(new ExprEditor() { 917 public void edit(MethodCall m) throws CannotCompileException { 918 m.replace( 919 "try { doit(); }" 920 + "catch(NullPointerException e){ init(); doit(); }"); 921 } 922 }); 923 924 final String src = 925 "try { doit(); }" 926 + "catch(NullPointerException e){ init(); doit(); return a; }"; 927 928 CtMethod p1 = cc.getDeclaredMethod("p1"); 929 p1.insertAfter(src, true); 930 931 cc.writeFile(); 932 Object obj = make(cc.getName()); 933 assertEquals(4, invoke(obj, "run")); 934 Object obj2 = make(cc.getName()); 935 assertEquals(4, invoke(obj2, "p1")); 936 } 937 938 private CtClass[] throwablesList = null; 939 testGetThrowables()940 public void testGetThrowables() throws Exception { 941 CtClass cc = sloader.get("test1.GetThrowables"); 942 CtMethod m1 = cc.getDeclaredMethod("run"); 943 m1.instrument(new ExprEditor() { 944 public void edit(MethodCall m) throws CannotCompileException { 945 throwablesList = m.mayThrow(); 946 } 947 }); 948 949 System.out.println(throwablesList[0].getName()); 950 System.out.println(throwablesList[1].getName()); 951 assertEquals(2, throwablesList.length); 952 } 953 testArrayAccess()954 public void testArrayAccess() throws Exception { 955 CtClass cc = sloader.get("test1.ArrayAccess"); 956 CtMethod m1 = cc.getDeclaredMethod("test"); 957 m1.insertBefore("{ ia[0] += 1; iaa[1] = iaa[0]; }"); 958 cc.writeFile(); 959 Object obj = make(cc.getName()); 960 assertEquals(8, invoke(obj, "test")); 961 } 962 testClinit()963 public void testClinit() throws Exception { 964 CtClass cc = sloader.get("test1.Clinit"); 965 CtConstructor clinit = cc.getClassInitializer(); 966 assertTrue(clinit != null); 967 try { 968 clinit.insertBeforeBody(";"); 969 assertTrue(false); 970 } 971 catch (CannotCompileException e) { 972 print(e.toString()); 973 assertEquals("class initializer", e.getReason()); 974 } 975 976 CtConstructor[] init = cc.getConstructors(); 977 assertEquals(1, init.length); 978 clinit.insertAfter("j += 1;"); 979 cc.writeFile(); 980 Object obj = make(cc.getName()); 981 assertEquals(457, invoke(obj, "run")); 982 } 983 testClinit2()984 public void testClinit2() throws Exception { 985 CtClass cc = sloader.get("test1.Clinit2"); 986 CtConstructor clinit = cc.makeClassInitializer(); 987 clinit.insertAfter("j = 7;"); 988 cc.writeFile(); 989 Object obj = make(cc.getName()); 990 assertEquals(7, invoke(obj, "run")); 991 } 992 993 // by yamazaki testCondExpr()994 public void testCondExpr() throws Exception { 995 CtClass cc = sloader.makeClass("test1.CondExpr"); 996 CtMethod methodM = new CtMethod(CtClass.intType, "m", 997 new CtClass[]{ CtClass.intType }, cc); 998 methodM.setModifiers(methodM.getModifiers() | Modifier.STATIC); 999 methodM.setBody("{if($1 <= 0) return 1; else return 0;}"); 1000 cc.addMethod(methodM); 1001 cc.writeFile(); 1002 Object obj = make(cc.getName()); 1003 assertEquals(0, invoke(obj, "m", 3)); 1004 } 1005 1006 // by yamazaki testCondExpr2()1007 public void testCondExpr2() throws Exception { 1008 CtClass cc = sloader.makeClass("test1.CondExpr2"); 1009 CtMethod methodM = new CtMethod(CtClass.intType, "m", 1010 new CtClass[]{ CtClass.intType }, cc); 1011 methodM.setModifiers(methodM.getModifiers() | Modifier.STATIC); 1012 methodM.setBody("{return ($1 <= 0) ? 1 : (m($1 - 1) * $1);}"); 1013 cc.addMethod(methodM); 1014 cc.writeFile(); 1015 Object obj = make(cc.getName()); 1016 assertEquals(6, invoke(obj, "m", 3)); 1017 } 1018 1019 // by yamazaki testCondExpr3()1020 public void testCondExpr3() throws Exception { 1021 CtClass cc = sloader.makeClass("test1.CondExpr3"); 1022 1023 CtMethod methodM = CtNewMethod.make( 1024 "public abstract int m(int i);", cc); 1025 CtMethod methodN = CtNewMethod.make( 1026 "public abstract int n(int i);", cc); 1027 cc.addMethod(methodM); 1028 cc.addMethod(methodN); 1029 1030 methodM.setBody("{return ($1 <= 0) ? 1 : (n($1 - 1) * $1);}"); 1031 methodN.setBody("{return m($1);}"); 1032 1033 cc.setModifiers(cc.getModifiers() & ~Modifier.ABSTRACT); 1034 1035 cc.writeFile(); 1036 Object obj = make(cc.getName()); 1037 assertEquals(6, invoke(obj, "m", 3)); 1038 } 1039 testDelegator()1040 public void testDelegator() throws Exception { 1041 CtClass cc = sloader.get("test1.Delegator"); 1042 1043 assertEquals("test1.SuperDelegator", cc.getSuperclass().getName()); 1044 1045 CtMethod f = sloader.getMethod("test1.SuperDelegator", "f"); 1046 CtMethod g = sloader.getMethod("test1.SuperDelegator", "g"); 1047 1048 cc.addMethod(CtNewMethod.delegator(f, cc)); 1049 cc.addMethod(CtNewMethod.delegator(g, cc)); 1050 1051 cc.writeFile(); 1052 Object obj = make(cc.getName()); 1053 assertEquals(15, invoke(obj, "run")); 1054 } 1055 testSetName()1056 public void testSetName() throws Exception { 1057 CtClass cc = sloader.get("test1.SetName"); 1058 CtMethod m0 = cc.getDeclaredMethod("foo"); 1059 cc.setName("test1.SetName2"); 1060 assertEquals(cc, sloader.get("test1.SetName2")); 1061 assertEquals("foo(Ltest1/SetName2;)", m0.getStringRep()); 1062 CtClass cc2 = sloader.makeClass("test1.SetName3"); 1063 CtMethod m = CtNewMethod.make( 1064 "public int m(test1.SetName2 obj) { return ((test1.SetName2)obj).i; }", 1065 cc2); 1066 cc2.addMethod(m); 1067 cc.writeFile(); 1068 cc2.writeFile(); 1069 } 1070 testFieldModifier()1071 public void testFieldModifier() throws Exception { 1072 CtClass cc = sloader.get("test1.FieldMod"); 1073 CtField f = cc.getField("text"); 1074 f.setModifiers(Modifier.PUBLIC); 1075 f = cc.getField("i"); 1076 f.setName("j"); 1077 cc.writeFile(); 1078 1079 Object obj = make(cc.getName()); 1080 assertEquals(java.lang.reflect.Modifier.PUBLIC, 1081 obj.getClass().getField("text").getModifiers()); 1082 assertTrue(obj.getClass().getField("j") != null); 1083 } 1084 testToString()1085 public void testToString() throws Exception { 1086 System.out.println(sloader.get("test1.FieldMod")); 1087 System.out.println(sloader.get("java.lang.Object")); 1088 } 1089 testPackage()1090 public void testPackage() throws Exception { 1091 Object obj = new Loader().loadClass("test1.Pac").getConstructor().newInstance(); 1092 assertEquals(1, invoke(obj, "run")); 1093 } 1094 testHoward()1095 public void testHoward() throws Exception { 1096 String head = 1097 "public Object lookup() throws java.rmi.RemoteException "; 1098 String src = 1099 "{ if (_remote != null) return _remote;" 1100 + " test1.HowardHome h = (test1.HowardHome)lookup(\"Howard\");" 1101 + " try { _remote = h.create(); }" 1102 + " catch (java.io.IOException e) { throw new java.rmi.RemoteException(e.getMessage(), e); }" 1103 + " return _remote; }"; 1104 1105 String src2 = 1106 "public void lookup2() {" 1107 + " try {}" 1108 + " catch (java.io.IOException e) { throw new Exception(e); }" 1109 + "}"; 1110 1111 CtClass cc = sloader.get("test1.Howard"); 1112 CtMethod m = CtNewMethod.make(head + src, cc); 1113 cc.addMethod(m); 1114 try { 1115 CtMethod m2 = CtNewMethod.make(src2, cc); 1116 cc.addMethod(m2); 1117 assertTrue(false); 1118 } 1119 catch (CannotCompileException e) {} 1120 1121 m = new CtMethod(sloader.get("java.lang.Object"), 1122 "lookup3", null, cc); 1123 m.setBody(src); 1124 m.setModifiers(Modifier.PUBLIC); 1125 m.setExceptionTypes(new CtClass[] { 1126 sloader.get("java.rmi.RemoteException") }); 1127 cc.addMethod(m); 1128 1129 cc.writeFile(); 1130 Object target = make(cc.getName()); 1131 Method mth = target.getClass().getMethod("lookup", new Class[0]); 1132 Object res = mth.invoke(target, new Object[0]); 1133 assertEquals("howard4", res); 1134 1135 mth = target.getClass().getMethod("lookup3", new Class[0]); 1136 res = mth.invoke(target, new Object[0]); 1137 assertEquals("howard4", res); 1138 } 1139 testLoop()1140 public void testLoop() throws Exception { 1141 CtClass cc = sloader.makeClass("test1.Loop"); 1142 CtMethod m = CtNewMethod.make( 1143 "public int run(int i) { int k = 0;" 1144 + "while (true) { if (k++ > 10) return i; } }", 1145 cc); 1146 cc.addMethod(m); 1147 cc.writeFile(); 1148 Object obj = make(cc.getName()); 1149 assertEquals(3, invoke(obj, "run", 3)); 1150 } 1151 suite()1152 public static Test suite() { 1153 TestSuite suite = new TestSuite("Javassist Tests"); 1154 suite.addTestSuite(JvstTest.class); 1155 suite.addTestSuite(JvstTest2.class); 1156 suite.addTestSuite(JvstTest3.class); 1157 suite.addTestSuite(JvstTest4.class); 1158 suite.addTestSuite(JvstTest5.class); 1159 suite.addTestSuite(LoaderTestByRandall.class); 1160 suite.addTestSuite(javassist.bytecode.BytecodeTest.class); 1161 suite.addTestSuite(javassist.bytecode.StackMapTest.class); 1162 suite.addTestSuite(javassist.compiler.CompTest.class); 1163 suite.addTestSuite(javassist.SetterTest.class); 1164 suite.addTestSuite(javassist.bytecode.InsertGap0.class); 1165 suite.addTestSuite(javassist.tools.reflect.LoaderTest.class); 1166 suite.addTestSuite(javassist.tools.CallbackTest.class); 1167 suite.addTestSuite(testproxy.ProxyTester.class); 1168 suite.addTestSuite(testproxy.ProxyFactoryPerformanceTest.class); // remove? 1169 suite.addTestSuite(javassist.proxyfactory.ProxyFactoryTest.class); 1170 suite.addTestSuite(javassist.proxyfactory.Tester.class); 1171 suite.addTestSuite(javassist.HotswapTest.class); 1172 suite.addTestSuite(test.javassist.proxy.ProxySerializationTest.class); 1173 suite.addTestSuite(test.javassist.convert.ArrayAccessReplaceTest.class); 1174 suite.addTestSuite(test.javassist.proxy.JASSIST113RegressionTest.class); 1175 suite.addTestSuite(test.javassist.proxy.JBPAPP9257Test.class); 1176 suite.addTestSuite(test.javassist.proxy.ProxyCacheGCTest.class); // remvoe? 1177 suite.addTestSuite(test.javassist.proxy.ProxyFactoryCompatibilityTest.class); 1178 suite.addTestSuite(test.javassist.proxy.ProxySerializationTest.class); 1179 suite.addTestSuite(test.javassist.proxy.ProxySimpleTest.class); 1180 suite.addTestSuite(test.javassist.bytecode.analysis.AnalyzerTest.class); 1181 suite.addTestSuite(test.javassist.convert.ArrayAccessReplaceTest.class); 1182 suite.addTestSuite(test.javassist.bytecode.analysis.DomTreeTest.class); 1183 return suite; 1184 } 1185 } 1186