if (explicitConstructorCall != null) {
explicitConstructor = explicitConstructorCall.binding;
if (explicitConstructor.alwaysNeedsAccessMethod()) {
- explicitConstructor = explicitConstructor.getAccessMethod();
+ explicitConstructor = explicitConstructor.getAccessMethod(true);
}
}
if (explicitConstructorCall != null && !(explicitConstructorCall.binding instanceof ProblemMethodBinding)) {
MethodBinding explicitConstructor = explicitConstructorCall.binding;
if (explicitConstructor.alwaysNeedsAccessMethod()) {
- explicitConstructor = explicitConstructor.getAccessMethod();
+ explicitConstructor = explicitConstructor.getAccessMethod(true);
}
import java.util.*;
import java.util.Arrays;
+import org.aspectj.ajdt.internal.compiler.lookup.*;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseWorld;
import org.aspectj.weaver.*;
import org.aspectj.weaver.ShadowMunger;
if (superBinding instanceof ProblemMethodBinding) {
return;
}
+ // InterTypeMethodBindings are always statically bound, so there's no
+ // need to treat super calls specially here
+ if (superBinding instanceof InterTypeMethodBinding) {
+ return;
+// InterTypeMethodBinding m = (InterTypeMethodBinding)superBinding;
+// if (m.postDispatchMethod != null) {
+// call.binding = m.postDispatchMethod;
+// }
+// return;
+ }
+
char[] accessName;
if (call.isSuperAccess() && !call.binding.isStatic()) {
call.receiver = new ThisReference();
import org.eclipse.jdt.internal.compiler.lookup.*;
public class InterTypeMethodBinding extends MethodBinding {
- //private ReferenceBinding withinType;
private ReferenceBinding targetType;
private MethodBinding syntheticMethod;
- //public MethodBinding introducedMethod;
+ public MethodBinding postDispatchMethod;
public AbstractMethodDeclaration sourceMethod;
if (signature.getKind() == Member.METHOD) {
syntheticMethod =
world.makeMethodBinding(AjcMemberMaker.interMethodDispatcher(signature, withinType));
+ postDispatchMethod =
+ world.makeMethodBinding(AjcMemberMaker.interMethodBody(signature, withinType));
} else {
syntheticMethod = world.makeMethodBinding(
AjcMemberMaker.interConstructor(world.resolve(signature.getDeclaringType()),
signature, withinType));
+ postDispatchMethod = syntheticMethod;
}
}
-
-//
-// this.declaringClass =
-//
-//
-//
-// char[] dispatch2Name;
-// if (Modifier.isPublic(modifiers)) {
-// dispatch2Name = name;
-// } else if (Modifier.isPrivate(modifiers)) {
-// dispatch2Name =
-// AstUtil.makeAjcMangledName("dispatch2".toCharArray(), withinType, selector);
-// } else {
-// // package visible
-// //??? optimize both in same package
-// dispatch2Name =
-// AstUtil.makeAjcMangledName("dispatch2".toCharArray(),
-// withinType.qualifiedPackageName(), selector);
-// }
-//
-// introducedMethod =
-// new MethodBinding(AstUtil.makePublic(modifiers), dispatch2Name,
-// type, args, exceptions, declaringClass);
-//
-// this.dispatchMethod =
-// new DispatchMethodBinding(introducedMethod, withinType, mangledParams);
-// }
-
//XXX this is identical to InterTypeFieldBinding
public boolean canBeSeenBy(TypeBinding receiverType, InvocationSite invocationSite, Scope scope) {
}
- public MethodBinding getAccessMethod() {
- return syntheticMethod;
+ public MethodBinding getAccessMethod(boolean staticReference) {
+ if (staticReference) return postDispatchMethod;
+ else return syntheticMethod;
}
public boolean alwaysNeedsAccessMethod() { return true; }
public void manageSyntheticAccessIfNecessary(BlockScope currentScope) {
if (binding.alwaysNeedsAccessMethod()) {
- syntheticAccessor = binding.getAccessMethod();
+ syntheticAccessor = binding.getAccessMethod(true);
return;
}
public void manageSyntheticAccessIfNecessary(BlockScope currentScope) {
if (binding.alwaysNeedsAccessMethod()) {
- syntheticAccessor = binding.getAccessMethod();
+ syntheticAccessor = binding.getAccessMethod(true);
return;
}
}
public void manageSyntheticAccessIfNecessary(BlockScope currentScope){
if (binding.alwaysNeedsAccessMethod()) {
- syntheticAccessor = binding.getAccessMethod();
+ syntheticAccessor = binding.getAccessMethod(isSuperAccess());
return;
}
* This will only be called if alwaysNeedsAccessMethod() returns true.
* In that case it should return the access method to be used.
*/
- public MethodBinding getAccessMethod() {
+ public MethodBinding getAccessMethod(boolean staticReference) {
throw new RuntimeException("unimplemented");
}
<compile files="AspectStaticInit.java"/>
<run class="AspectStaticInit"/>
</ajc-test>
+
+ <ajc-test dir="bugs" pr="29959"
+ title="super call in intertype method declaration body causes VerifyError">
+ <compile files="SuperToIntro.java"/>
+ <run class="SuperToIntro"/>
+ </ajc-test>
</suite>
<message kind="warning" line="73"/>
</compile>
</ajc-test>
+
+ <ajc-test dir="bugs" pr="29959"
+ title="super call in intertype method declaration body causes VerifyError">
+ <compile files="SuperToIntro.java"/>
+ <run class="SuperToIntro"/>
+ </ajc-test>
+
</suite>
--- /dev/null
+// from Bug#: 29959
+import org.aspectj.testing.Tester;
+
+aspect Foo {
+ String A.onlyA() { return "onlyA"; }
+ String A.foo() { return "Afoo"; }
+ String B.foo() { return super.foo() + ":" + onlyA() + ":" + super.getName(); }
+}
+
+class A {
+ String getName() { return "A"; }
+}
+class B extends A {
+ String getName() { return "B"; }
+
+ String onB1() { return foo() + ":" + onlyA() + ":" + getName(); }
+ String onB2() { return super.foo() + ":" + super.onlyA() + ":" + super.getName(); }
+}
+
+public class SuperToIntro {
+ public static void main(String[] args) {
+ B b = new B();
+ Tester.checkEqual(b.foo(), "Afoo:onlyA:A");
+ Tester.checkEqual(b.onB1(), "Afoo:onlyA:A:onlyA:B");
+ Tester.checkEqual(b.onB2(), "Afoo:onlyA:A");
+ }
+}
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">
<suite>
- <ajc-test dir="bugs" pr="29691"
- title="Static inner aspects cannot reference user defined pointcuts">
- <compile files="PcdLookup.java" />
- <run class="PcdLookup"/>
- </ajc-test>
+
+
+
<!--
- <ajc-test dir="new"
- title="work nicely with inner class method look-up rules and call-site advice"
- keywords="from-resolved_10x">
- <compile files="InnerMethods.java"/>
- <run class="InnerMethods"/>
- </ajc-test>
+
-->
</suite>
\ No newline at end of file