aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2004-01-14 11:12:27 +0000
committeracolyer <acolyer>2004-01-14 11:12:27 +0000
commit5c4db9cb620918dcf064ddbfc50f54130d3b2cab (patch)
treeaac96c5782acfad95f20ccb6f50e930c083a96a0
parentb8d42c06d69f44e8c87a9b7d3ea290de0d18ed37 (diff)
downloadaspectj-5c4db9cb620918dcf064ddbfc50f54130d3b2cab.tar.gz
aspectj-5c4db9cb620918dcf064ddbfc50f54130d3b2cab.zip
Fix for Bugzilla Bug 49784
declaring interface methods should work as it does in interface and Bugzilla Bug 45676 AspectJ enhanced code can not be used with plain old java anymo and Bugzilla Bug 43972 Static crosscutting makes interfaces unusable for javac
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java27
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java2
-rw-r--r--tests/ajcTests.xml114
-rw-r--r--tests/ajcTestsFailing.xml34
-rw-r--r--tests/bugs/abstractMethods/abstractClass/B.java7
-rw-r--r--tests/bugs/abstractMethods/abstractClass/C.java6
-rw-r--r--tests/bugs/abstractMethods/abstractClass/jars/AandB.jarbin0 -> 1527 bytes
-rw-r--r--tests/bugs/abstractMethods/interface/A.java5
-rw-r--r--tests/bugs/abstractMethods/interface/B.java1
-rw-r--r--tests/bugs/abstractMethods/interface/C.java5
-rw-r--r--tests/bugs/abstractMethods/interface/jars/AandB.jarbin0 -> 1476 bytes
-rw-r--r--tests/bugs/abstractMethods/singlesource/C.java14
-rw-r--r--tests/bugs/abstractMethods/singlesource/C1.java17
-rw-r--r--tests/bugs/abstractMethods/singlesource/C2.java16
-rw-r--r--tests/bugs/interfaceDefinition/Main1.java8
-rw-r--r--tests/bugs/interfaceDefinition/pack/DefineInterface.java1
16 files changed, 211 insertions, 46 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
index 8d9146a00..45db5b357 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
@@ -20,6 +20,7 @@ import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.Proceed;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.util.FuzzyBoolean;
+import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.ConcreteTypeMunger;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedTypeX;
@@ -49,7 +50,7 @@ import org.eclipse.jdt.core.compiler.CharOperation;
public class AjProblemReporter extends ProblemReporter {
private static final boolean DUMP_STACK = false;
- public EclipseFactory world;
+ public EclipseFactory factory;
public AjProblemReporter(
IErrorHandlingPolicy policy,
@@ -64,17 +65,17 @@ public class AjProblemReporter extends ProblemReporter {
TypeBinding exceptionType,
ASTNode location)
{
- if (!world.getWorld().getDeclareSoft().isEmpty()) {
- Shadow callSite = world.makeShadow(location, referenceContext);
- Shadow enclosingExec = world.makeShadow(referenceContext);
+ if (!factory.getWorld().getDeclareSoft().isEmpty()) {
+ Shadow callSite = factory.makeShadow(location, referenceContext);
+ Shadow enclosingExec = factory.makeShadow(referenceContext);
// System.err.println("about to show error for unhandled exception: " + new String(exceptionType.sourceName()) +
// " at " + location + " in " + referenceContext);
- for (Iterator i = world.getWorld().getDeclareSoft().iterator(); i.hasNext(); ) {
+ for (Iterator i = factory.getWorld().getDeclareSoft().iterator(); i.hasNext(); ) {
DeclareSoft d = (DeclareSoft)i.next();
// We need the exceptionType to match the type in the declare soft statement
// This means it must either be the same type or a subtype
- ResolvedTypeX throwException = world.fromEclipse((ReferenceBinding)exceptionType);
+ ResolvedTypeX throwException = factory.fromEclipse((ReferenceBinding)exceptionType);
FuzzyBoolean isExceptionTypeOrSubtype =
d.getException().matchesInstanceof(throwException);
if (!isExceptionTypeOrSubtype.alwaysTrue() ) continue;
@@ -140,16 +141,22 @@ public class AjProblemReporter extends ProblemReporter {
return;
}
-
// if we implemented this method by an inter-type declaration, then there is no error
//??? be sure this is always right
- ResolvedTypeX onTypeX = world.fromEclipse(type); //abstractMethod.declaringClass);
+ ResolvedTypeX onTypeX = factory.fromEclipse(type); //abstractMethod.declaringClass);
for (Iterator i = onTypeX.getInterTypeMungers().iterator(); i.hasNext(); ) {
ConcreteTypeMunger m = (ConcreteTypeMunger)i.next();
if (m.matches(onTypeX)) {
ResolvedMember sig = m.getSignature();
- if (Modifier.isPublic(sig.getModifiers()) && !Modifier.isAbstract(sig.getModifiers())) {
- if (ResolvedTypeX.matches(sig, world.makeResolvedMember(abstractMethod))) {
+ if (!Modifier.isAbstract(sig.getModifiers())) {
+ if (ResolvedTypeX
+ .matches(
+ AjcMemberMaker.interMethod(
+ sig,
+ m.getAspectType(),
+ sig.getDeclaringType().isInterface(
+ factory.getWorld())),
+ EclipseFactory.makeResolvedMember(abstractMethod))) {
return;
}
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
index 9ab6abd65..368ef0064 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
@@ -366,7 +366,7 @@ public class AjBuildManager {
// ew.setLint(bcelWorld.getLint());
// ew.setXnoInline(buildConfig.isXnoInline());
le.factory = factory;
- pr.world = factory;
+ pr.factory = factory;
le.factory.buildManager = this;
compiler.lookupEnvironment = le;
diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml
index 4cb3a62c6..8b48f4cda 100644
--- a/tests/ajcTests.xml
+++ b/tests/ajcTests.xml
@@ -6971,4 +6971,118 @@
</compile>
<run class="AfterThrowingCtor"/>
</ajc-test>
+
+ <ajc-test dir="bugs/abstractMethods" pr="49784"
+ title="Introduced abstract method on abstract class not implemented by subtype">
+ <compile files="abstractClass/C.java"
+ aspectpath="abstractClass/jars/AandB.jar">
+ <message kind="error" line="1"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs/abstractMethods" pr="49784"
+ title="Introduced abstract method on interface not implemented by subtype (weave altogether)">
+ <compile files="interface/C.java,interface/A.java,interface/B.java" />
+ <run class="C"/>
+ </ajc-test>
+
+
+ <ajc-test dir="bugs/abstractMethods" pr="49784"
+ title="Introduced abstract method on interface not implemented by subtype (injars)">
+ <compile files="interface/C.java,interface/jars/AandB.jar">
+ <message kind="error" line="1"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs/abstractMethods" pr="49784"
+ title="Introduced abstract method on interface not implemented by subtype (aspectpath)">
+ <compile files="interface/C.java"
+ aspectpath="interface/jars/AandB.jar" />
+ <run class="C"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs/abstractMethods" pr="49784"
+ title="Introduced abstract method on abstract class not implemented by subtype (single source file)">
+ <compile files="singlesource/C.java">
+ <message kind="error" line="9"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs/abstractMethods" pr="49784"
+ title="Introduced abstract method on abstract class with introduced concrete method (single source file)">
+ <compile files="singlesource/C1.java"/>
+ <run class="C1"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs/abstractMethods" pr="49784"
+ title="Introduced abstract method on abstract class with existing concrete method (single source file)">
+ <compile files="singlesource/C2.java"/>
+ <run class="C2"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs/interAbstract"
+ pr="49784"
+ title="aspect declares interface method (no modifiers)">
+ <compile files="InterfaceMethodDeclarationNone.java" >
+ <message kind="error" line="32" text="requires a body" />
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs/interAbstract"
+ pr="49784"
+ title="aspect declares interface method (abstract)">
+ <compile files="InterfaceMethodDeclarationAbstract.java">
+ <message kind="error" line="40" text="must implement" />
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs/interAbstract"
+ pr="49784"
+ comment="working in 1.1.1 - keep with others?"
+ title="aspect declares interface method (public abstract)">
+ <compile files="InterfaceMethodDeclarationFull.java" />
+ <run class="InterfaceMethodDeclarationFull"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs/interfaceDefinition"
+ pr="43972"
+ title="Use class implementing interface via aspect (not woven together)">
+ <compile
+ files="pack/DefineInterface.java,
+ pack/InterfaceDefinition.java,
+ pack/MyInterface.java"/>
+ <run class="pack.InterfaceDefinition"/>
+ <compile
+ includeClassesDir="true"
+ files="Main.java">
+ <message kind="error" line="3"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs/interfaceDefinition"
+ pr="43972"
+ title="Use class implementing interface via aspect (weave all together)">
+ <compile
+ files="pack/DefineInterface.java,
+ pack/InterfaceDefinition.java,
+ pack/MyInterface.java,
+ Main.java"/>
+ <run class="pack.InterfaceDefinition"/>
+ <run class="Main"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs/interfaceDefinition"
+ pr="43972"
+ title="Use class implementing interface via aspect (only one implementer)">
+ <compile
+ files="pack/DefineInterface.java,
+ pack/InterfaceDefinition.java,
+ pack/MyInterface.java"/>
+ <run class="pack.InterfaceDefinition"/>
+ <compile
+ includeClassesDir="true"
+ files="Main1.java"/>
+ <run class="Main1"/>
+ </ajc-test>
+
</suite>
diff --git a/tests/ajcTestsFailing.xml b/tests/ajcTestsFailing.xml
index 1e87072b4..8c66d13bb 100644
--- a/tests/ajcTestsFailing.xml
+++ b/tests/ajcTestsFailing.xml
@@ -119,20 +119,6 @@
</compile>
<run class="org.aspectj.langlib.PointcutsCW"/>
</ajc-test>
-
- <ajc-test dir="bugs/interfaceDefinition"
- pr="43972"
- title="Use class implementing interface via aspect">
- <compile
- files="pack/DefineInterface.java,
- pack/InterfaceDefinition.java,
- pack/MyInterface.java"/>
- <run class="pack.InterfaceDefinition"/>
- <compile
- includeClassesDir="true"
- files="Main.java"/>
- <run class="Main"/>
- </ajc-test>
<ajc-test dir="new"
pr="42668"
@@ -151,27 +137,7 @@
<run class="SubtypeConstructorCW"/>
</ajc-test>
- <ajc-test dir="bugs/interAbstract"
- pr="49784"
- title="aspect declares interface method (no modifiers)">
- <compile files="InterfaceMethodDeclarationNone.java" />
- <run class="InterfaceMethodDeclarationNone"/>
- </ajc-test>
-
- <ajc-test dir="bugs/interAbstract"
- pr="49784"
- title="aspect declares interface method (abstract)">
- <compile files="InterfaceMethodDeclarationAbstract.java" />
- <run class="InterfaceMethodDeclarationAbstract"/>
- </ajc-test>
- <ajc-test dir="bugs/interAbstract"
- pr="49784"
- comment="working in 1.1.1 - keep with others?"
- title="aspect declares interface method (public abstract)">
- <compile files="InterfaceMethodDeclarationFull.java" />
- <run class="InterfaceMethodDeclarationFull"/>
- </ajc-test>
</suite>
diff --git a/tests/bugs/abstractMethods/abstractClass/B.java b/tests/bugs/abstractMethods/abstractClass/B.java
new file mode 100644
index 000000000..e63e581b7
--- /dev/null
+++ b/tests/bugs/abstractMethods/abstractClass/B.java
@@ -0,0 +1,7 @@
+abstract class B {}
+
+aspect A {
+ abstract void B.m();
+
+ public static void doit(B b) { b.m(); }
+} \ No newline at end of file
diff --git a/tests/bugs/abstractMethods/abstractClass/C.java b/tests/bugs/abstractMethods/abstractClass/C.java
new file mode 100644
index 000000000..04b499e96
--- /dev/null
+++ b/tests/bugs/abstractMethods/abstractClass/C.java
@@ -0,0 +1,6 @@
+public class C extends B {
+ public static void main(String[] args) {
+ A.doit(new C());
+ }
+}
+
diff --git a/tests/bugs/abstractMethods/abstractClass/jars/AandB.jar b/tests/bugs/abstractMethods/abstractClass/jars/AandB.jar
new file mode 100644
index 000000000..4ca677f97
--- /dev/null
+++ b/tests/bugs/abstractMethods/abstractClass/jars/AandB.jar
Binary files differ
diff --git a/tests/bugs/abstractMethods/interface/A.java b/tests/bugs/abstractMethods/interface/A.java
new file mode 100644
index 000000000..3eed777e4
--- /dev/null
+++ b/tests/bugs/abstractMethods/interface/A.java
@@ -0,0 +1,5 @@
+aspect A {
+ void B.m(){}
+
+ public static void doit(B b) { b.m(); }
+} \ No newline at end of file
diff --git a/tests/bugs/abstractMethods/interface/B.java b/tests/bugs/abstractMethods/interface/B.java
new file mode 100644
index 000000000..a09e44742
--- /dev/null
+++ b/tests/bugs/abstractMethods/interface/B.java
@@ -0,0 +1 @@
+interface B {} \ No newline at end of file
diff --git a/tests/bugs/abstractMethods/interface/C.java b/tests/bugs/abstractMethods/interface/C.java
new file mode 100644
index 000000000..99fc42f3d
--- /dev/null
+++ b/tests/bugs/abstractMethods/interface/C.java
@@ -0,0 +1,5 @@
+public class C implements B {
+ public static void main(String[] args) {
+ A.doit(new C());
+ }
+}
diff --git a/tests/bugs/abstractMethods/interface/jars/AandB.jar b/tests/bugs/abstractMethods/interface/jars/AandB.jar
new file mode 100644
index 000000000..9d71c0c87
--- /dev/null
+++ b/tests/bugs/abstractMethods/interface/jars/AandB.jar
Binary files differ
diff --git a/tests/bugs/abstractMethods/singlesource/C.java b/tests/bugs/abstractMethods/singlesource/C.java
new file mode 100644
index 000000000..ddbc91b46
--- /dev/null
+++ b/tests/bugs/abstractMethods/singlesource/C.java
@@ -0,0 +1,14 @@
+abstract class B {}
+
+aspect A {
+ abstract void B.m();
+
+ public static void doit(B b) { b.m(); }
+}
+
+public class C extends B {
+ public static void main(String[] args) {
+ A.doit(new C());
+ }
+}
+
diff --git a/tests/bugs/abstractMethods/singlesource/C1.java b/tests/bugs/abstractMethods/singlesource/C1.java
new file mode 100644
index 000000000..881d00015
--- /dev/null
+++ b/tests/bugs/abstractMethods/singlesource/C1.java
@@ -0,0 +1,17 @@
+abstract class B {}
+
+aspect A {
+ abstract void B.m();
+
+ public static void doit(B b) { b.m(); }
+}
+
+public class C1 extends B {
+ public static void main(String[] args) {
+ A.doit(new C1());
+ }
+}
+
+aspect A1 {
+ void C1.m() {}
+}
diff --git a/tests/bugs/abstractMethods/singlesource/C2.java b/tests/bugs/abstractMethods/singlesource/C2.java
new file mode 100644
index 000000000..545fc9daa
--- /dev/null
+++ b/tests/bugs/abstractMethods/singlesource/C2.java
@@ -0,0 +1,16 @@
+abstract class B {}
+
+aspect A {
+ public abstract void B.m();
+
+ public static void doit(B b) { b.m(); }
+}
+
+public class C2 extends B {
+ public static void main(String[] args) {
+ A.doit(new C2());
+ }
+
+ public void m() {}
+}
+
diff --git a/tests/bugs/interfaceDefinition/Main1.java b/tests/bugs/interfaceDefinition/Main1.java
new file mode 100644
index 000000000..b942dc7df
--- /dev/null
+++ b/tests/bugs/interfaceDefinition/Main1.java
@@ -0,0 +1,8 @@
+
+/** @testcase PR#43972 Use class implementing interface via aspect */
+public class Main1 {
+ public static void main(String[] args) {
+ pack.MyInterface i = new pack.InterfaceDefinition.C();
+ i.m();
+ }
+}
diff --git a/tests/bugs/interfaceDefinition/pack/DefineInterface.java b/tests/bugs/interfaceDefinition/pack/DefineInterface.java
index 0e3df5dc8..2fab84f74 100644
--- a/tests/bugs/interfaceDefinition/pack/DefineInterface.java
+++ b/tests/bugs/interfaceDefinition/pack/DefineInterface.java
@@ -7,7 +7,6 @@ public aspect DefineInterface {
declare parents: InterfaceDefinition.C implements MyInterface;
static {
Tester.expectEvent("m()");
- Tester.expectEvent("p()");
}
public void MyInterface.m() {
Tester.event("m()");