From 98c78c9c39384fa1c4734097308e5b38f1f83072 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 13 Aug 2004 14:48:43 +0000 Subject: [PATCH] Fix and tests for Bugzilla Bug 71372 NoSuchMethodError calling private method from around advice in inner aspect --- .../compiler/ast/AccessForInlineVisitor.java | 18 +++++++---- .../systemtest/ajc121/Ajc121Tests.java | 30 ++++++++++++++++++- .../systemtest/ajc121/ajc121-tests.xml | 27 ++++++++++++++++- 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 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + -- 2.39.5