diff options
-rw-r--r-- | src/test/javassist/JvstTest.java | 8 | ||||
-rw-r--r-- | src/test/test1/FieldInit.java | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/test/javassist/JvstTest.java b/src/test/javassist/JvstTest.java index c6825fd0..d28c0654 100644 --- a/src/test/javassist/JvstTest.java +++ b/src/test/javassist/JvstTest.java @@ -103,6 +103,10 @@ public class JvstTest extends JvstTestRoot { cc.addField(f2); CtField f3 = CtField.make("public int f3;", cc); cc.addField(f3); + CtField f4 = CtField.make("public int f4 = this.f2 + 3;", cc); + cc.addField(f4); + CtField fi = CtField.make("public test1.FieldInit.FI fi = new test1.FieldInit.FI(this);", cc); + cc.addField(fi); testFieldInitHash = f1.hashCode(); cc.writeFile(); Object obj = make(cc.getName()); @@ -112,6 +116,10 @@ public class JvstTest extends JvstTestRoot { assertEquals(3, value2); int value3 = obj.getClass().getField("f3").getInt(obj); assertEquals(0, value3); + int value4 = obj.getClass().getField("f4").getInt(obj); + assertEquals(6, value4); + Object obfi = obj.getClass().getField("fi").get(obj); + assertTrue(obfi.getClass().getField("fi").get(obfi) == obj); } /* test CodeIterator.insertExGap(). diff --git a/src/test/test1/FieldInit.java b/src/test/test1/FieldInit.java index 87f5a3bc..ee483149 100644 --- a/src/test/test1/FieldInit.java +++ b/src/test/test1/FieldInit.java @@ -14,4 +14,11 @@ public class FieldInit { --loop; } while (loop > 0); } + + public static class FI { + public FieldInit fi; + public FI(FieldInit fi) { + this.fi = fi; + } + } } |