From: aclement Date: Fri, 23 Jan 2009 20:38:58 +0000 (+0000) Subject: 262218: test and fix X-Git-Tag: pre268419~206 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ab75342042aa9a5e0ed0c512bf50d68f9bfb2d19;p=aspectj.git 262218: test and fix --- diff --git a/tests/multiIncremental/pr262218/base/src/generics/ActionExecutor.java b/tests/multiIncremental/pr262218/base/src/generics/ActionExecutor.java new file mode 100644 index 000000000..e323cc01a --- /dev/null +++ b/tests/multiIncremental/pr262218/base/src/generics/ActionExecutor.java @@ -0,0 +1,18 @@ +package generics; + +public class ActionExecutor { + public static void main(String[] args) { + DeleteAction d = new DeleteAction() { + public String getSelected() { + throw new RuntimeException(); + } + + }; + d.delete2++; + d.delete3.add(null); + } + + void nothing2(DeleteAction g) { + g.delete2++; + } +} \ No newline at end of file diff --git a/tests/multiIncremental/pr262218/base/src/generics/DeleteAction.java b/tests/multiIncremental/pr262218/base/src/generics/DeleteAction.java new file mode 100644 index 000000000..05c136a3d --- /dev/null +++ b/tests/multiIncremental/pr262218/base/src/generics/DeleteAction.java @@ -0,0 +1,12 @@ +package generics; +import java.util.List; + + +public interface DeleteAction{ + + public void delete(); + + public T getSelected(); + +} + \ No newline at end of file diff --git a/tests/multiIncremental/pr262218/base/src/generics/DeleteActionAspect.aj b/tests/multiIncremental/pr262218/base/src/generics/DeleteActionAspect.aj new file mode 100644 index 000000000..499981e37 --- /dev/null +++ b/tests/multiIncremental/pr262218/base/src/generics/DeleteActionAspect.aj @@ -0,0 +1,30 @@ +package generics; + +import java.util.List; + + +public aspect DeleteActionAspect { + + public void DeleteAction.delete() { + Object selected = getSelected(); + selected.toString(); + delete3.add(""); + } + + public int DeleteAction.delete2; + + public List DeleteAction.delete3; + + + public static void main(String[] args) { + DeleteAction d = new DeleteAction() { + public String getSelected() { + throw new RuntimeException(); + } + + }; + d.delete2++; + d.delete3.add(null); + } + +} \ No newline at end of file diff --git a/tests/multiIncremental/pr262218/base/src/test/Demo.aj b/tests/multiIncremental/pr262218/base/src/test/Demo.aj new file mode 100644 index 000000000..174680bc8 --- /dev/null +++ b/tests/multiIncremental/pr262218/base/src/test/Demo.aj @@ -0,0 +1,14 @@ +package test; + +import java.util.List; + +public class Demo { + + void g() { + new Demo(7).foo(null); + x++; + this.x++; + MyAspect.aspectOf(); + MyAspect.hasAspect(); + } +} \ No newline at end of file diff --git a/tests/multiIncremental/pr262218/base/src/test/MyAspect.aj b/tests/multiIncremental/pr262218/base/src/test/MyAspect.aj new file mode 100644 index 000000000..7d3efc989 --- /dev/null +++ b/tests/multiIncremental/pr262218/base/src/test/MyAspect.aj @@ -0,0 +1,50 @@ +package test; +import java.util.List; + +public aspect MyAspect { + List Demo.list = null; + declare @type : Demo : @Deprecated; + int Demo.x = 5; + + void Demo.foo(List x) { + MyAspect.hasAspect(); + } + + public Demo.new(int x) { + this(); + } + + declare warning : execution(* *.nothing(..)) : "blah"; + + declare error : execution(* *.nothing(..)) : "blah"; + + declare soft : Exception : execution(* *.nothing(..)); + + + protected pointcut s(): + call(String Demo.toString(..)); + + before (): s() { + } + after (): s() { + } + void around (): s() { + proceed(); + return; + } + after () returning(): s() { + } + after () throwing(): s() { + thisEnclosingJoinPointStaticPart.getClass(); + thisJoinPoint.getClass(); + thisJoinPointStaticPart.getClass(); + } + + @interface MyAnnotation { } + + // try out declare annotation + declare @field: int Demo.x: @MyAnnotation; + declare @method: void Demo.foo(..): @MyAnnotation; + declare @constructor: public Demo.new(int): @MyAnnotation; + +} diff --git a/tests/multiIncremental/pr262218/base/src/test/OtherClass.aj b/tests/multiIncremental/pr262218/base/src/test/OtherClass.aj new file mode 100644 index 000000000..a24940d9c --- /dev/null +++ b/tests/multiIncremental/pr262218/base/src/test/OtherClass.aj @@ -0,0 +1,10 @@ +package test; + + +public class OtherClass { + void x() { + Demo d = new Demo(4); + d.foo(null); + d.x ++; + } +} \ No newline at end of file diff --git a/tests/multiIncremental/pr262218/base/src/test2/MyAspect2.aj b/tests/multiIncremental/pr262218/base/src/test2/MyAspect2.aj new file mode 100644 index 000000000..5f79df23d --- /dev/null +++ b/tests/multiIncremental/pr262218/base/src/test2/MyAspect2.aj @@ -0,0 +1,29 @@ +package test2; + +import test.Demo; +import test2.MyAspect2; + +public aspect MyAspect2 { + + static interface Bar { + + } + declare parents : Demo implements Bar, Cloneable; + + public int Bar.bar() { + return 7; + } + + + static class Foo { + public Foo() { + + } + } + declare parents : Demo extends Foo; + + public int Foo.baz() { + return 7; + } + +} diff --git a/tests/multiIncremental/pr262218/base/src/test2/OtherClass2.aj b/tests/multiIncremental/pr262218/base/src/test2/OtherClass2.aj new file mode 100644 index 000000000..5922fa931 --- /dev/null +++ b/tests/multiIncremental/pr262218/base/src/test2/OtherClass2.aj @@ -0,0 +1,15 @@ +package test2; + +import test.Demo; + +public class OtherClass2 { + void x() { + Demo d = new Demo(4); + d.bar(); + d.baz(); + // causes error for now see note at end of AJCompilationUnitProblemFinder.isARealProblem +// ((MyAspect2.Bar) d).bar(); + ((MyAspect2.Foo) d).baz(); + ((Cloneable) d).toString(); + } +} \ No newline at end of file diff --git a/tests/multiIncremental/pr262218/inc1/src/test/MyAspect.aj b/tests/multiIncremental/pr262218/inc1/src/test/MyAspect.aj new file mode 100644 index 000000000..e655e5954 --- /dev/null +++ b/tests/multiIncremental/pr262218/inc1/src/test/MyAspect.aj @@ -0,0 +1,51 @@ +package test; +import java.util.List; + + +public aspect MyAspect { + List Demo.list = null; + declare @type : Demo : @Deprecated; + int Demo.x = 5; + + void Demo.foo(List x) { + MyAspect.hasAspect(); + } + + public Demo.new(int x) { + this(); + } + + declare warning : execution(* *.nothing(..)) : "blah"; + + declare error : execution(* *.nothing(..)) : "blah"; + + declare soft : Exception : execution(* *.nothing(..)); + + + protected pointcut s(): + call(String Demo.toString(..)); + + before (): s() { + } + after (): s() { + } + void around (): s() { + proceed(); + return; + } + after () returning(): s() { + } + after () throwing(): s() { + thisEnclosingJoinPointStaticPart.getClass(); + thisJoinPoint.getClass(); + thisJoinPointStaticPart.getClass(); + } + + @interface MyAnnotation { } + + // try out declare annotation + declare @field: int Demo.x: @MyAnnotation; + declare @method: void Demo.foo(..): @MyAnnotation; + declare @constructor: public Demo.new(int): @MyAnnotation; + +} diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 8e8eb585f..90a81d457 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -70,18 +70,19 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } assertEquals("Should have found the two types in: " + ps, 2, count); } - + public void testConstructorAdvice_pr261380() throws Exception { String p = "261380"; initialiseProject(p); build(p); IRelationshipMap irm = getModelFor(p).getRelationshipMap(); - IRelationship ir = (IRelationship)irm.get("=261380())",handle); + assertEquals("Expected the handle for the code node inside the constructor decl", + "=261380())", handle); } /* @@ -244,6 +245,19 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa assertEquals("=BrokenHandles