diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/pureJava/ConstructorFlow.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/pureJava/ConstructorFlow.java')
-rw-r--r-- | tests/pureJava/ConstructorFlow.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/pureJava/ConstructorFlow.java b/tests/pureJava/ConstructorFlow.java new file mode 100644 index 000000000..a0a8f36fe --- /dev/null +++ b/tests/pureJava/ConstructorFlow.java @@ -0,0 +1,37 @@ + +import org.aspectj.testing.Tester; +import org.aspectj.testing.Tester; + +/** @testcase from biojava: org/biojava/bio/dp/SimpleMarkovModel.java:384 */ +public class ConstructorFlow { + final Runnable runner; // remove final and compile succeeds + Runnable nonfinal; + String one; + /** @testcase PUREJAVA flow analysis where final variable set in another constructor */ + public ConstructorFlow(String one, String two) { + this(one); + runner.run(); // incorrect CE: Field runner might not have a value + nonfinal.run(); // expecting NPE + } + + public ConstructorFlow(String one) { + this.one = one; + runner = new Runnable() { + public void run() { + Tester.event("runner.run()"); + }}; + } + + public static void main(String[] args) { + Tester.expectEvent("NullPointerException"); + Tester.expectEvent("runner.run()"); + try { + new ConstructorFlow("one", "two"); + Tester.check(false, "expected NPE"); + } catch (NullPointerException npe) { + Tester.event("NullPointerException"); + } + Tester.checkAllEvents(); + } +} + |