]> source.dussan.org Git - aspectj.git/commitdiff
Fix for bug 69459
authoraclement <aclement>
Tue, 27 Jul 2004 14:17:32 +0000 (14:17 +0000)
committeraclement <aclement>
Tue, 27 Jul 2004 14:17:32 +0000 (14:17 +0000)
   Hiding of Instance Methods by static methods

13 files changed:
tests/ajcTests.xml
tests/bugs/intertypeOverrides/Aspect1.class [new file with mode: 0644]
tests/bugs/intertypeOverrides/Aspect1.java [new file with mode: 0644]
tests/bugs/intertypeOverrides/Aspect2.class [new file with mode: 0644]
tests/bugs/intertypeOverrides/Aspect2.java [new file with mode: 0644]
tests/bugs/intertypeOverrides/IntertypeOverrides.java [new file with mode: 0644]
tests/bugs/intertypeOverrides/IntertypeOverrides2.java [new file with mode: 0644]
tests/bugs/intertypeOverrides/Subclass.class [new file with mode: 0644]
tests/bugs/intertypeOverrides/Subclass.java [new file with mode: 0644]
tests/bugs/intertypeOverrides/Super.class [new file with mode: 0644]
tests/bugs/intertypeOverrides/Superclass.class [new file with mode: 0644]
tests/bugs/intertypeOverrides/Superclass.java [new file with mode: 0644]
weaver/src/org/aspectj/weaver/ResolvedTypeX.java

index a74b3d915bd21959c85ab76b06de28abf5b93f2c..85c36164b80785d1fb3a39c8965979d41d4aa236 100644 (file)
         <message kind="error" line="9" text="can't bind type name 'unknown.Error'"/>
         </compile>
     </ajc-test> 
+    
+    <ajc-test dir="bugs/intertypeOverrides"
+               pr="69459" title="Hiding of Instance Methods by static methods">
+        <compile files="IntertypeOverrides.java">
+          <message kind="error" line="8" text="void Sub.m() cannot override void Super.m(); overriding method is static"/>
+        </compile>
+        <compile files="IntertypeOverrides2.java">
+          <message kind="error" line="8" text="void Sub.m() cannot override void Super.m(); overridden method is static"/>
+        </compile>
+        <compile files="Superclass.java,Subclass.java,Aspect1.java">
+          <message file="Aspect1.java" kind="error" line="2" 
+             text="void Subclass.staticMethod() cannot override void Superclass.staticMethod(); overridden method is static"/>
+        </compile>
+        <compile files="Superclass.java,Subclass.java,Aspect2.java">
+          <message file="Aspect2.java" kind="error" line="2"
+             text="void Subclass.nonstaticMethod() cannot override void Superclass.nonstaticMethod(); overriding method is static"/>
+        </compile>
+    </ajc-test>
+    
 </suite>
diff --git a/tests/bugs/intertypeOverrides/Aspect1.class b/tests/bugs/intertypeOverrides/Aspect1.class
new file mode 100644 (file)
index 0000000..824e468
Binary files /dev/null and b/tests/bugs/intertypeOverrides/Aspect1.class differ
diff --git a/tests/bugs/intertypeOverrides/Aspect1.java b/tests/bugs/intertypeOverrides/Aspect1.java
new file mode 100644 (file)
index 0000000..e6dbf8b
--- /dev/null
@@ -0,0 +1,3 @@
+aspect Aspect1 {
+  public void Subclass.staticMethod() {};
+}
diff --git a/tests/bugs/intertypeOverrides/Aspect2.class b/tests/bugs/intertypeOverrides/Aspect2.class
new file mode 100644 (file)
index 0000000..f4421e9
Binary files /dev/null and b/tests/bugs/intertypeOverrides/Aspect2.class differ
diff --git a/tests/bugs/intertypeOverrides/Aspect2.java b/tests/bugs/intertypeOverrides/Aspect2.java
new file mode 100644 (file)
index 0000000..b2ea3ca
--- /dev/null
@@ -0,0 +1,3 @@
+aspect Aspect2 {
+  public static void Subclass.nonstaticMethod() {};
+}
diff --git a/tests/bugs/intertypeOverrides/IntertypeOverrides.java b/tests/bugs/intertypeOverrides/IntertypeOverrides.java
new file mode 100644 (file)
index 0000000..895a49b
--- /dev/null
@@ -0,0 +1,9 @@
+class Super {
+  public void m(){};
+}
+
+class Sub extends Super {}
+
+aspect A {
+  public static void Sub.m(){}
+}
diff --git a/tests/bugs/intertypeOverrides/IntertypeOverrides2.java b/tests/bugs/intertypeOverrides/IntertypeOverrides2.java
new file mode 100644 (file)
index 0000000..ae86cc3
--- /dev/null
@@ -0,0 +1,9 @@
+class Super {
+  public static void m(){};
+}
+
+class Sub extends Super {}
+
+aspect A {
+  public void Sub.m(){}
+}
diff --git a/tests/bugs/intertypeOverrides/Subclass.class b/tests/bugs/intertypeOverrides/Subclass.class
new file mode 100644 (file)
index 0000000..c0a203f
Binary files /dev/null and b/tests/bugs/intertypeOverrides/Subclass.class differ
diff --git a/tests/bugs/intertypeOverrides/Subclass.java b/tests/bugs/intertypeOverrides/Subclass.java
new file mode 100644 (file)
index 0000000..b87d7c8
--- /dev/null
@@ -0,0 +1,2 @@
+class Subclass extends Superclass {
+}
diff --git a/tests/bugs/intertypeOverrides/Super.class b/tests/bugs/intertypeOverrides/Super.class
new file mode 100644 (file)
index 0000000..0a91a00
Binary files /dev/null and b/tests/bugs/intertypeOverrides/Super.class differ
diff --git a/tests/bugs/intertypeOverrides/Superclass.class b/tests/bugs/intertypeOverrides/Superclass.class
new file mode 100644 (file)
index 0000000..6b0ea6b
Binary files /dev/null and b/tests/bugs/intertypeOverrides/Superclass.class differ
diff --git a/tests/bugs/intertypeOverrides/Superclass.java b/tests/bugs/intertypeOverrides/Superclass.java
new file mode 100644 (file)
index 0000000..eface6c
--- /dev/null
@@ -0,0 +1,4 @@
+class Superclass {
+  public static void staticMethod(){} {}
+  public void nonstaticMethod() {};
+}
index 15c86bdbb6ed24b11151031e264ec1a9ed422f91..16634af0761e7519832310027bed5d8c1b6a250e 100644 (file)
@@ -1107,9 +1107,9 @@ public abstract class ResolvedTypeX extends TypeX {
                ResolvedMember sig = munger.getSignature();
                while (existingMembers.hasNext()) {
                        ResolvedMember existingMember = (ResolvedMember)existingMembers.next();
-                       
+                       //System.err.println("Comparing munger: "+sig+" with member "+existingMember);
                        if (conflictingSignature(existingMember, munger.getSignature())) {
-                               //System.err.println("conflict: " + existingMember + " with " + munger);
+                               //System.err.println("conflict: existingMember=" + existingMember + "   typeMunger=" + munger);
                                //System.err.println(munger.getSourceLocation() + ", " + munger.getSignature() + ", " + munger.getSignature().getSourceLocation());
                                
                                if (isVisible(existingMember.getModifiers(), this, munger.getAspectType())) {
@@ -1191,7 +1191,15 @@ public abstract class ResolvedTypeX extends TypeX {
                                                
                        return false;
                }
-               
+               if (parent.isStatic() && !child.isStatic()) {
+                       world.showMessage(IMessage.ERROR,
+                         child.toString()+" cannot override "+parent.toString()+"; overridden method is static",
+                         child.getSourceLocation(),null);
+               } else if (child.isStatic() && !parent.isStatic()) {
+                       world.showMessage(IMessage.ERROR,
+                         child.toString()+" cannot override "+parent.toString()+"; overriding method is static",
+                         child.getSourceLocation(),null);
+               }
                return true;
                
        }