]> source.dussan.org Git - aspectj.git/commitdiff
fixed Bug 29959: super call in intertype method declaration body causes VerifyError
authorjhugunin <jhugunin>
Thu, 13 Feb 2003 21:00:35 +0000 (21:00 +0000)
committerjhugunin <jhugunin>
Thu, 13 Feb 2003 21:00:35 +0000 (21:00 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java
tests/ajcTests.xml
tests/ajcTestsFailing.xml
tests/bugs/SuperToIntro.java [new file with mode: 0644]
tests/jimTests.xml

index 55ddb12f69d7460f3e262aa613441e06ca00e19c..5abe2ce07fe53cfda05c4ac2fa614dbe0c3ec38e 100644 (file)
@@ -110,7 +110,7 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration {
                if (explicitConstructorCall != null) {
                        explicitConstructor = explicitConstructorCall.binding;
                        if (explicitConstructor.alwaysNeedsAccessMethod()) {
-                               explicitConstructor = explicitConstructor.getAccessMethod();
+                               explicitConstructor = explicitConstructor.getAccessMethod(true);
                        }
                }
                
@@ -226,7 +226,7 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration {
                if (explicitConstructorCall != null && !(explicitConstructorCall.binding instanceof ProblemMethodBinding)) {
                        MethodBinding explicitConstructor = explicitConstructorCall.binding;
                        if (explicitConstructor.alwaysNeedsAccessMethod()) {
-                               explicitConstructor = explicitConstructor.getAccessMethod();
+                               explicitConstructor = explicitConstructor.getAccessMethod(true);
                        }
                        
                        
index 00732e4eb506f4a308de13bd134fc858a217370c..74d071b6ca25f95ad0a7d602251a1e6da300b361 100644 (file)
@@ -16,6 +16,7 @@ package org.aspectj.ajdt.internal.compiler.ast;
 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;
@@ -49,6 +50,17 @@ public class SuperFixerVisitor extends AbstractSyntaxTreeVisitorAdapter {
                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();
index 18aea28e430155f6368cb6a6b5f79efa7cbb31e1..fac054a2d579fecf1f6fe8f2c72b85793074415a 100644 (file)
@@ -18,11 +18,10 @@ import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
 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;
        
@@ -38,42 +37,17 @@ public class InterTypeMethodBinding extends MethodBinding {
                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) {
@@ -127,8 +101,9 @@ public class InterTypeMethodBinding extends MethodBinding {
        }
 
 
-       public MethodBinding getAccessMethod() {
-               return syntheticMethod;
+       public MethodBinding getAccessMethod(boolean staticReference) {
+               if (staticReference) return postDispatchMethod;
+               else return syntheticMethod;
        }
        
        public boolean alwaysNeedsAccessMethod() { return true; }
index 57bf855724824945d571d5deab023c1b0a826518..c8ccc2864dfba3ea1c2d97c294af07d6d42c9dd4 100644 (file)
@@ -155,7 +155,7 @@ public class AllocationExpression
 
        public void manageSyntheticAccessIfNecessary(BlockScope currentScope) {
                if (binding.alwaysNeedsAccessMethod()) {
-                       syntheticAccessor = binding.getAccessMethod();
+                       syntheticAccessor = binding.getAccessMethod(true);
                        return;
                }
                
index 6a871d7fff09eb8a13c4c3ffe24c7ddaad8c85dc..ddfb729a461ebc079915cdedc791ef73bbf3285a 100644 (file)
@@ -181,7 +181,7 @@ public class ExplicitConstructorCall
 
        public void manageSyntheticAccessIfNecessary(BlockScope currentScope) {
                if (binding.alwaysNeedsAccessMethod()) {
-                       syntheticAccessor = binding.getAccessMethod();
+                       syntheticAccessor = binding.getAccessMethod(true);
                        return;
                }
                
index a05394370a9268509f6d4ac2a6b32861999592c9..cd68794eb0665656fa527a5d9658cfd13e725b92 100644 (file)
@@ -142,7 +142,7 @@ public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope) {
 }
 public void manageSyntheticAccessIfNecessary(BlockScope currentScope){
        if (binding.alwaysNeedsAccessMethod()) {
-               syntheticAccessor = binding.getAccessMethod();
+               syntheticAccessor = binding.getAccessMethod(isSuperAccess());
                return;
        }
 
index c8e5d99794aa3fd057efb8a6353daa9d619a23f2..49982a3593bc6401bb2750c95f0d811f7de3fca6 100644 (file)
@@ -421,7 +421,7 @@ public final int sourceStart() {
         * 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");
        }
 
index 58ac77e35f31f573f78b1574d5db4b5d7a5dbc23..1d0501dd6fff8e15b62a9ea4f921df069e0e289b 100644 (file)
         <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>
index dd0d786736e0376e015eb1a5ed29b28d9728cd86..4bdd8def6f5650032f03812f0e99a6eab75dc84c 100644 (file)
             <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>
diff --git a/tests/bugs/SuperToIntro.java b/tests/bugs/SuperToIntro.java
new file mode 100644 (file)
index 0000000..81c25bf
--- /dev/null
@@ -0,0 +1,27 @@
+// 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");
+  }
+}
index 23f82d378324d94093a7b29fab3806251fdd8cfb..0a867d719264f3774b5bd18f9fa62ad4cddbbb67 100644 (file)
@@ -1,18 +1,11 @@
 <!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