aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShigeru Chiba <chibash@users.noreply.github.com>2017-11-14 03:22:25 +0900
committerGitHub <noreply@github.com>2017-11-14 03:22:25 +0900
commit468b2391594bd5dcebdb275ff1f19b824ad57b6a (patch)
treec59238764e71d86f9e5a03227729514ee012c6e2
parent2ed997c0159f53f6257bfe894684badf05f94d8a (diff)
parentf4ce4aa16c768acebdafb288aeb097c22eee7bb7 (diff)
downloadjavassist-468b2391594bd5dcebdb275ff1f19b824ad57b6a.tar.gz
javassist-468b2391594bd5dcebdb275ff1f19b824ad57b6a.zip
Merge pull request #166 from nickl-/test-ctfield-make-with-this
Unit Test: CtField.make referencing 'this'.
-rw-r--r--src/test/javassist/JvstTest.java8
-rw-r--r--src/test/test1/FieldInit.java7
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;
+ }
+ }
}