diff options
author | Andy Clement <andrew.clement@gmail.com> | 2012-06-15 11:29:35 -0700 |
---|---|---|
committer | Andy Clement <andrew.clement@gmail.com> | 2012-06-15 11:29:35 -0700 |
commit | ba9d43ccaf2660ddc9916ea48f79a77ba60d435e (patch) | |
tree | 6f73f5ae340be4559e5551ec6d51b80447dc627f | |
parent | 4b101d9686d97db694585c94d742c4dcb8417aaa (diff) | |
download | aspectj-ba9d43ccaf2660ddc9916ea48f79a77ba60d435e.tar.gz aspectj-ba9d43ccaf2660ddc9916ea48f79a77ba60d435e.zip |
382723
-rw-r--r-- | org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java | 11 | ||||
-rw-r--r-- | tests/bugs170/pr382723/Foo.java | 44 | ||||
-rw-r--r-- | tests/bugs170/pr382723/FooAspect.java | 35 | ||||
-rw-r--r-- | tests/bugs170/pr382723/FooAspect2.java | 35 | ||||
-rw-r--r-- | tests/bugs170/pr382723/FooAspect3.java | 35 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java | 20 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc170/ajc170.xml | 33 |
7 files changed, 212 insertions, 1 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java index 91833c9e6..0755476e9 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java @@ -40,6 +40,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; @@ -259,8 +260,16 @@ public class AccessForInlineVisitor extends ASTVisitor { return; // has already produced an error if (binding instanceof ReferenceBinding) { ReferenceBinding rb = (ReferenceBinding) binding; - if (!rb.isPublic()) + if (!rb.isPublic()) { + try { + if (rb instanceof ParameterizedTypeBinding) { + rb = (ReferenceBinding) rb.erasure(); + } + } catch (Throwable t) { // TODO remove post 1.7.0 + t.printStackTrace(); + } handler.notePrivilegedTypeAccess(rb, null); // ??? + } } else if (binding instanceof ArrayBinding) { makePublic(((ArrayBinding) binding).leafComponentType); } else { diff --git a/tests/bugs170/pr382723/Foo.java b/tests/bugs170/pr382723/Foo.java new file mode 100644 index 000000000..cbb32b914 --- /dev/null +++ b/tests/bugs170/pr382723/Foo.java @@ -0,0 +1,44 @@ +import java.util.AbstractList; +import java.util.LinkedList; +import java.util.List; + +abstract aspect FooAspectParent<T extends List> { + protected int getNumber(int k) { + return -1*k; + } +} + +abstract privileged aspect FooAspect<T extends AbstractList> extends FooAspectParent<T> { + pointcut pc(): call(T.new()) && !within(Bar); + + T around():pc() { + System.out.println("superaspect getNumber returns "+getNumber(2)); + System.out.println("abstract method returns "+method()); + localMethod(); + Math.random(); //<-- works + hashCode(); //<-- works + return null; + } + + private void localMethod(){} + + protected abstract T method(); +} + +aspect Bar extends FooAspect<LinkedList> { + protected LinkedList method() { + System.out.println("Bar.method() running"); + return new LinkedList(); + } +} + +public class Foo { + + public static void main(String[] argv) { + new Foo().bar(); + } + public LinkedList bar() { + new LinkedList(); + return null; + } +} diff --git a/tests/bugs170/pr382723/FooAspect.java b/tests/bugs170/pr382723/FooAspect.java new file mode 100644 index 000000000..5b5c866c5 --- /dev/null +++ b/tests/bugs170/pr382723/FooAspect.java @@ -0,0 +1,35 @@ +import java.util.AbstractList; +import java.util.LinkedList; +import java.util.List; + +abstract aspect FooAspectParent<T extends List> { + protected int getNumber(int k) { + return -1*k; + } +} + +abstract privileged aspect FooAspect<T extends AbstractList> extends FooAspectParent<T> { + pointcut pc(): call(T.new()); + + T around():pc() { + //getNumber(1); //<-- method call to superAspect fails + method(); // <-- method call to abstract local defined method fails + //localMethod(); //<-- method call to local private method fails + Math.random(); //<-- works + hashCode(); //<-- works + return null; + } + + private void localMethod(){} + + protected abstract T method(); +} + +/* +class Foo { + public LinkedList bar() { + new LinkedList(); + return null; + } +} +*/ diff --git a/tests/bugs170/pr382723/FooAspect2.java b/tests/bugs170/pr382723/FooAspect2.java new file mode 100644 index 000000000..d0faa53c4 --- /dev/null +++ b/tests/bugs170/pr382723/FooAspect2.java @@ -0,0 +1,35 @@ +import java.util.AbstractList; +import java.util.LinkedList; +import java.util.List; + +abstract aspect FooAspectParent<T extends List> { + protected int getNumber(int k) { + return -1*k; + } +} + +abstract privileged aspect FooAspect<T extends AbstractList> extends FooAspectParent<T> { + pointcut pc(): call(T.new()); + + T around():pc() { + getNumber(1); //<-- method call to superAspect fails + //method(); // <-- method call to abstract local defined method fails + //localMethod(); //<-- method call to local private method fails + Math.random(); //<-- works + hashCode(); //<-- works + return null; + } + + private void localMethod(){} + + protected abstract T method(); +} + +/* +class Foo { + public LinkedList bar() { + new LinkedList(); + return null; + } +} +*/ diff --git a/tests/bugs170/pr382723/FooAspect3.java b/tests/bugs170/pr382723/FooAspect3.java new file mode 100644 index 000000000..f0a034505 --- /dev/null +++ b/tests/bugs170/pr382723/FooAspect3.java @@ -0,0 +1,35 @@ +import java.util.AbstractList; +import java.util.LinkedList; +import java.util.List; + +abstract aspect FooAspectParent<T extends List> { + protected int getNumber(int k) { + return -1*k; + } +} + +abstract privileged aspect FooAspect<T extends AbstractList> extends FooAspectParent<T> { + pointcut pc(): call(T.new()); + + T around():pc() { + //getNumber(1); //<-- method call to superAspect fails + //method(); // <-- method call to abstract local defined method fails + localMethod(); //<-- method call to local private method fails + Math.random(); //<-- works + hashCode(); //<-- works + return null; + } + + private void localMethod(){} + + protected abstract T method(); +} + +/* +class Foo { + public LinkedList bar() { + new LinkedList(); + return null; + } +} +*/ diff --git a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java index 3896a93ab..3585e782a 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java @@ -38,6 +38,26 @@ public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // public void testLostAnnos_377130_2() { // runTest("missing annos on priv aspects - 2"); // } + + public void testGenericAspectAround382723() { + runTest("generic aspect"); + } + + public void testGenericAspectAround382723_2() { + runTest("generic aspect 2"); + } + + public void testGenericAspectAround382723_3() { + runTest("generic aspect 3"); + } + + public void testGenericAspectAround382723_4() { + runTest("generic aspect 4"); + } + +// public void testCovariantGenericsItd382189() { +// runTest("covariant generics"); +// } public void testAttributeErrorJ7() { runTest("attribute issue with J7"); diff --git a/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml b/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml index 459ba902c..05ebd0ee2 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml +++ b/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml @@ -2,6 +2,39 @@ <suite> + <ajc-test dir="bugs170/pr382723" title="generic aspect"> + <compile files="FooAspect.java" options="-1.5"/> + </ajc-test> + + <ajc-test dir="bugs170/pr382723" title="generic aspect 2"> + <compile files="FooAspect2.java" options="-1.5"/> + </ajc-test> + + <ajc-test dir="bugs170/pr382723" title="generic aspect 3"> + <compile files="FooAspect3.java" options="-1.5"/> + </ajc-test> + + <ajc-test dir="bugs170/pr382723" title="generic aspect 4"> + <compile files="Foo.java" options="-1.5 -showWeaveInfo"> + <message kind="weave" text="Join point 'constructor-call(void java.util.LinkedList.<init>())' in Type 'Foo' (Foo.java:41) advised by around advice from 'Bar' (Foo.java:14)"/> + </compile> + <run class="Foo"> + <stdout> + <line text="superaspect getNumber returns -2"/> + <line text="Bar.method() running"/> + <line text="abstract method returns []"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs170/pr382189" title="covariant generics"> + <compile files="covbug/A.java covbug/A_ITD.aj covbug/B.java covbug/SuperA.java covbug/SuperB.java" options="-1.5"/> + <!-- <run class="Foo"> + <stdout> + <line text="@Anno()"/></stdout> + </run> --> + </ajc-test> + <ajc-test dir="bugs170/pr377130" title="missing annos on priv aspects"> <compile files="Foo.java" options="-1.5"/> <run class="Foo"> |