From ba9d43ccaf2660ddc9916ea48f79a77ba60d435e Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 15 Jun 2012 11:29:35 -0700 Subject: [PATCH] 382723 --- .../compiler/ast/AccessForInlineVisitor.java | 11 ++++- tests/bugs170/pr382723/Foo.java | 44 +++++++++++++++++++ tests/bugs170/pr382723/FooAspect.java | 35 +++++++++++++++ tests/bugs170/pr382723/FooAspect2.java | 35 +++++++++++++++ tests/bugs170/pr382723/FooAspect3.java | 35 +++++++++++++++ .../systemtest/ajc170/Ajc170Tests.java | 20 +++++++++ .../org/aspectj/systemtest/ajc170/ajc170.xml | 33 ++++++++++++++ 7 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 tests/bugs170/pr382723/Foo.java create mode 100644 tests/bugs170/pr382723/FooAspect.java create mode 100644 tests/bugs170/pr382723/FooAspect2.java create mode 100644 tests/bugs170/pr382723/FooAspect3.java 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 { + protected int getNumber(int k) { + return -1*k; + } +} + +abstract privileged aspect FooAspect extends FooAspectParent { + 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 { + 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 { + protected int getNumber(int k) { + return -1*k; + } +} + +abstract privileged aspect FooAspect extends FooAspectParent { + 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 { + protected int getNumber(int k) { + return -1*k; + } +} + +abstract privileged aspect FooAspect extends FooAspectParent { + 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 { + protected int getNumber(int k) { + return -1*k; + } +} + +abstract privileged aspect FooAspect extends FooAspectParent { + 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 @@ -37,6 +37,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() { 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.39.5