aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2004-01-07 15:57:25 +0000
committeracolyer <acolyer>2004-01-07 15:57:25 +0000
commit7322131ad6d3c5c14114a6b7945757f45d438112 (patch)
treed19e5d14588607c94eb9975e87330f68d8174f1f
parent01055e854df883746321b955bd5b9b41a840feda (diff)
downloadaspectj-7322131ad6d3c5c14114a6b7945757f45d438112.tar.gz
aspectj-7322131ad6d3c5c14114a6b7945757f45d438112.zip
fix for pr 47754, itd of static method on interface
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java7
-rw-r--r--tests/ajcTests.xml8
-rw-r--r--tests/bugs/StaticInterfaceMethods.java10
3 files changed, 25 insertions, 0 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
index 2039fd54c..404d74373 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
@@ -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");
+ }
+ }
}
diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml
index 3b834af69..cdeece3b6 100644
--- a/tests/ajcTests.xml
+++ b/tests/ajcTests.xml
@@ -6835,4 +6835,12 @@
<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
index 000000000..fb08f0db4
--- /dev/null
+++ b/tests/bugs/StaticInterfaceMethods.java
@@ -0,0 +1,10 @@
+interface StaticInterfaceMethods {
+
+}
+
+aspect A {
+
+ static int StaticInterfaceMethods.aMethod() {
+ return 1;
+ }
+} \ No newline at end of file