summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java18
-rw-r--r--tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java30
-rw-r--r--tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml27
3 files changed, 68 insertions, 7 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 c913040fe..9840be79e 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
@@ -170,16 +170,24 @@ public class AccessForInlineVisitor extends ASTVisitor {
if (isPublic(binding)) return binding;
if (binding instanceof InterTypeMethodBinding) return binding;
+ ResolvedMember m = null;
if (binding.isPrivate() && binding.declaringClass != inAspect.binding) {
+ // does this always mean that the aspect is an inner aspect of the bindings
+ // declaring class? After all, the field is private but we can see it from
+ // where we are.
binding.modifiers = AstUtil.makePackageVisible(binding.modifiers);
+ m = EclipseFactory.makeResolvedMember(binding);
+ } else {
+ // Sometimes receiverType and binding.declaringClass are *not* the same.
+
+ // Sometimes receiverType is a subclass of binding.declaringClass. In these situations
+ // we want the generated inline accessor to call the method on the subclass (at
+ // runtime this will be satisfied by the super).
+ m = EclipseFactory.makeResolvedMember(binding, receiverType);
}
-
-
- ResolvedMember m = EclipseFactory.makeResolvedMember(binding, receiverType);
if (inAspect.accessForInline.containsKey(m)) return (MethodBinding)inAspect.accessForInline.get(m);
MethodBinding ret = world.makeMethodBinding(
- AjcMemberMaker.inlineAccessMethodForMethod(inAspect.typeX, m)
- );
+ AjcMemberMaker.inlineAccessMethodForMethod(inAspect.typeX, m));
inAspect.accessForInline.put(m, ret);
return ret;
}
diff --git a/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java b/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java
index 0e5654ec6..1d7964940 100644
--- a/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java
@@ -180,7 +180,35 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void test034_scopeForITDS_pr61768() {
runTest("scope for inter-type methods");
- }
+ }
+
+ public void test035_innerAspectCallsPrivateMethod_pr71372() {
+ runTest("NoSuchMethodError calling private method from around advice in inner aspect");
+ String s = getLastRunResult().getStdErr();
+ assertTrue("Expected ':before:around' but got "+s,
+ s.equals(":before:around"));
+ }
+
+ public void test036_innerAspectCallsPrivateMethod_pr71372_2() {
+ runTest("NoSuchMethodError calling private method from around advice in inner aspect (2)");
+ String s = getLastRunResult().getStdErr();
+ assertTrue("Expected ':before:around' but got "+s,
+ s.equals(":before:around"));
+ }
+
+ public void test037_innerAspectCallsPrivateMethod_pr71372_3() {
+ runTest("NoSuchMethodError calling private method from around advice in inner aspect (3)");
+ String s = getLastRunResult().getStdErr();
+ assertTrue("Expected ':before:around' but got "+s,
+ s.equals(":before:around"));
+ }
+
+ public void test038_innerAspectCallsPrivateMethod_pr71372_4() {
+ runTest("NoSuchMethodError calling private method from around advice in inner aspect (4)");
+ String s = getLastRunResult().getStdErr();
+ assertTrue("Expected ':before:around' but got "+s,
+ s.equals(":before:around"));
+ }
}
diff --git a/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml b/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml
index c11ce0228..1ebf21c7a 100644
--- a/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml
+++ b/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml
@@ -279,4 +279,29 @@
<compile files="PR61768.java">
<message kind="error" line="37" text="No enclosing instance of type Aspect is accessible"/>
</compile>
- </ajc-test> \ No newline at end of file
+ </ajc-test>
+
+ <ajc-test dir="bugs/doYouHaveVisiblePrivates" pr="71372"
+ title="NoSuchMethodError calling private method from around advice in inner aspect">
+ <compile files="PrivateCall.java"/>
+ <run class="PrivateCall"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs/doYouHaveVisiblePrivates" pr="71372"
+ title="NoSuchMethodError calling private method from around advice in inner aspect (2)">
+ <compile files="PrivateCall2.java,PrivateCall3.java"/>
+ <run class="def.PrivateCall3"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs/doYouHaveVisiblePrivates" pr="71372"
+ title="NoSuchMethodError calling private method from around advice in inner aspect (3)">
+ <compile files="PrivateCallInstance.java"/>
+ <run class="PrivateCallInstance"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs/doYouHaveVisiblePrivates" pr="71372"
+ title="NoSuchMethodError calling private method from around advice in inner aspect (4)">
+ <compile files="PrivateCall_Instance_Package1.java,PrivateCall_Instance_Package2.java"/>
+ <run class="def.PrivateCall_Instance_Package2"/>
+ </ajc-test>
+