You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JvstTest.java 43KB

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