]> source.dussan.org Git - aspectj.git/commitdiff
fix for pr 47754, itd of static method on interface
authoracolyer <acolyer>
Wed, 7 Jan 2004 15:57:25 +0000 (15:57 +0000)
committeracolyer <acolyer>
Wed, 7 Jan 2004 15:57:25 +0000 (15:57 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
tests/ajcTests.xml
tests/bugs/StaticInterfaceMethods.java [new file with mode: 0644]

index 2039fd54ca9dcc947b98f99a576425f934e81f46..404d74373731575c821ab0515d7d8b2b98ad2082 100644 (file)
@@ -73,6 +73,13 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
        }
        public void resolveStatements() {
                if (!Modifier.isAbstract(declaredModifiers)) super.resolveStatements();
+               if (Modifier.isStatic(declaredModifiers)) {
+                       // Check the target for ITD is not an interface
+                       if (onTypeBinding.isInterface()) {
+                               scope.problemReporter().signalError(sourceStart, sourceEnd,
+                                       "methods in interfaces cannot be declared static");
+                       }
+               }
        }
        
        
index 3b834af69b675a6df792e762c44ffa7f8115f7a0..cdeece3b6b5d4b5e6fd7b28b0888b106dfd0ab07 100644 (file)
                <message kind="error" line="6" text="Unhandled exception"/>
         </compile>
     </ajc-test>
+    
+    <ajc-test dir="bugs" pr="47754"
+      title="static method introduction on interfaces, should not be allowed">
+        <compile files="StaticInterfaceMethods.java">
+                 <message kind="error" line="7" text="methods in interfaces cannot be declared static"/>
+        </compile>
+    </ajc-test>
+
 </suite>
diff --git a/tests/bugs/StaticInterfaceMethods.java b/tests/bugs/StaticInterfaceMethods.java
new file mode 100644 (file)
index 0000000..fb08f0d
--- /dev/null
@@ -0,0 +1,10 @@
+interface StaticInterfaceMethods {
+       
+}
+
+aspect A {
+       
+       static int StaticInterfaceMethods.aMethod() {
+               return 1;
+       }
+}
\ No newline at end of file