Browse Source

Fix and tests for Bugzilla Bug 71372

	  	NoSuchMethodError calling private method from around advice in inner aspect
tags/V1_2_1
aclement 20 years ago
parent
commit
98c78c9c39

+ 13
- 5
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java View File

@@ -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;
}

+ 29
- 1
tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java View File

@@ -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"));
}

}


+ 26
- 1
tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml View File

@@ -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>
</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>


Loading…
Cancel
Save