aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2002-12-24 00:34:36 +0000
committerjhugunin <jhugunin>2002-12-24 00:34:36 +0000
commit045686fb7995a6eb490cc3d81b30a4b1834b6568 (patch)
treecee22fcd30b6f60e1fc9f6d63c7767396977f419
parentd3156f737f3bb24e3ad695205da5977bef519275 (diff)
downloadaspectj-045686fb7995a6eb490cc3d81b30a4b1834b6568.tar.gz
aspectj-045686fb7995a6eb490cc3d81b30a4b1834b6568.zip
correctly handling exceptions thrown from intro methods
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java1
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java9
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java23
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/WorkingTestMain.java20
-rw-r--r--weaver/src/org/aspectj/weaver/AjcMemberMaker.java22
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedMember.java4
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedTypeX.java22
9 files changed, 85 insertions, 20 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
index d32e2c009..31ce89eef 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
@@ -204,7 +204,7 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration {
ResolvedMember signature =
new ResolvedMember(Member.CONSTRUCTOR, declaringTypeX, declaredModifiers,
ResolvedTypeX.VOID, "<init>", bindingAsMember.getParameterTypes());
-
+ signature.setCheckedExceptions(world.fromEclipse(binding.thrownExceptions));
ResolvedMember syntheticInterMember =
AjcMemberMaker.interConstructor(declaringTypeX, signature, aspectType);
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
index fba705bc6..b2c735a90 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java
@@ -136,4 +136,6 @@ public abstract class InterTypeDeclaration extends MethodDeclaration {
}
protected abstract Shadow.Kind getShadowKindForBody();
+
+ public ResolvedMember getSignature() { return munger.getSignature(); }
}
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 899d5ec6b..e3fea33e7 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
@@ -79,6 +79,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
ResolvedMember sig = new ResolvedMember(Member.METHOD, EclipseWorld.fromBinding(onTypeBinding),
declaredModifiers, EclipseWorld.fromBinding(binding.returnType), new String(declaredSelector),
EclipseWorld.fromBindings(binding.parameters));
+ sig.setCheckedExceptions(world.fromEclipse(binding.thrownExceptions));
NewMethodTypeMunger myMunger = new NewMethodTypeMunger(sig, null);
setMunger(myMunger);
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java
index 5f362ccc3..3fbf2203d 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java
@@ -13,6 +13,7 @@
package org.aspectj.ajdt.internal.compiler.lookup;
+import org.aspectj.ajdt.internal.compiler.ast.*;
import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
import org.aspectj.bridge.SourceLocation;
import org.aspectj.weaver.*;
@@ -114,6 +115,14 @@ public class EclipseShadow extends Shadow {
Shadow.Kind kind;
if (e instanceof AdviceDeclaration) {
kind = Shadow.AdviceExecution;
+ } else if (e instanceof InterTypeMethodDeclaration) {
+ return new EclipseShadow(world, Shadow.MethodExecution,
+ ((InterTypeDeclaration)e).getSignature(), astNode, context);
+ } else if (e instanceof InterTypeConstructorDeclaration) {
+ return new EclipseShadow(world, Shadow.ConstructorExecution,
+ ((InterTypeDeclaration)e).getSignature(), astNode, context);
+ } else if (e instanceof InterTypeFieldDeclaration) {
+ return null;
} else if (e instanceof MethodDeclaration) {
kind = Shadow.MethodExecution;
} else if (e instanceof ConstructorDeclaration) {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java
index 7ada86e4f..272127064 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java
@@ -140,14 +140,15 @@ public class EclipseWorld extends World {
}
public static ResolvedMember makeResolvedMember(MethodBinding binding) {
- return new ResolvedMember(
+ ResolvedMember ret = new ResolvedMember(
binding.isConstructor() ? Member.CONSTRUCTOR : Member.METHOD,
fromBinding(binding.declaringClass),
binding.modifiers,
fromBinding(binding.returnType),
new String(binding.selector),
fromBindings(binding.parameters));
- //XXX need to add checked exceptions
+ ret.setCheckedExceptions(fromBindings(binding.thrownExceptions));
+ return ret;
}
public static ResolvedMember makeResolvedMember(FieldBinding binding) {
@@ -202,6 +203,17 @@ public class EclipseWorld extends World {
}
return ret;
}
+
+
+ private ReferenceBinding[] makeReferenceBindings(TypeX[] types) {
+ int len = types.length;
+ ReferenceBinding[] ret = new ReferenceBinding[len];
+
+ for (int i = 0; i < len; i++) {
+ ret[i] = (ReferenceBinding)makeTypeBinding(types[i]);
+ }
+ return ret;
+ }
public FieldBinding makeFieldBinding(ResolvedMember member) {
@@ -214,16 +226,15 @@ public class EclipseWorld extends World {
public MethodBinding makeMethodBinding(ResolvedMember member) {
- if (member.getExceptions() != null && member.getExceptions().length > 0) {
- throw new RuntimeException("unimplemented");
- }
return new MethodBinding(member.getModifiers(),
member.getName().toCharArray(),
makeTypeBinding(member.getReturnType()),
makeTypeBindings(member.getParameterTypes()),
- new ReferenceBinding[0],
+ makeReferenceBindings(member.getExceptions()),
(ReferenceBinding)makeTypeBinding(member.getDeclaringType()));
}
+
+
public MethodBinding makeMethodBindingForCall(Member member) {
return new MethodBinding(member.getCallsiteModifiers(),
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/WorkingTestMain.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/WorkingTestMain.java
index b70be133f..f2273f1b3 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/WorkingTestMain.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/WorkingTestMain.java
@@ -21,8 +21,8 @@ import org.aspectj.testing.util.TestUtil;
public class WorkingTestMain {
public static void main(String[] args1) throws IOException {
- //testExamples();
- testOne();
+ testExamples();
+ //testOne();
}
public static void testOne() throws IOException {
@@ -67,7 +67,7 @@ public class WorkingTestMain {
//TestUtil.runMain("out;../lib/test/testing-client.jar", "AroundInnerCalls");
}
- private static String examplesDir = "c:/aspectj/examples/";
+ private static String examplesDir = "../docs/dist/doc/examples/";
private static void example(String[] argfiles, String[] classes) {
List args = new ArrayList();
args.add("-verbose");
@@ -90,11 +90,11 @@ public class WorkingTestMain {
public static void testExamples() throws IOException {
-// example(new String[] {"observer/files.lst"},
-// new String[] {"observer.Demo"});
+ example(new String[] {"observer/files.lst"},
+ new String[] {}); // don't run the gui
-// example(new String[] {"tjp/files.lst"},
-// new String[] {"tjp.Demo"});
+ example(new String[] {"tjp/files.lst"},
+ new String[] {"tjp.Demo"});
example(new String[] {"telecom/timing.lst"},
new String[] {"telecom.TimingSimulation"});
@@ -122,12 +122,12 @@ public class WorkingTestMain {
new String[] {"bean.Demo"});
example(new String[] {"spacewar/demo.lst"},
- new String[] {});
+ new String[] {}); // don't run the gui
example(new String[] {"spacewar/debug.lst"},
- new String[] {});
-
+ new String[] {}); // don't run the gui
+ System.out.println("done!!!!!!!!!!!!!!!!!!!!");
}
}
diff --git a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
index 7996af37f..2c9a89916 100644
--- a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
+++ b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
@@ -361,12 +361,22 @@ public class AjcMemberMaker {
);
}
+
+// private static int makeFieldModifiers(int declaredModifiers) {
+// int ret = Modifier.PUBLIC;
+// if (Modifier.isTransient(declaredModifiers)) ret |= Modifier.TRANSIENT;
+// if (Modifier.isVolatile(declaredModifiers)) ret |= Modifier.VOLATILE;
+// return ret;
+// }
+
+
/**
* This field goes on the class the field
* is declared onto
*/
public static ResolvedMember interFieldClassField(ResolvedMember field, TypeX aspectType) {
- return new ResolvedMember(Member.FIELD, field.getDeclaringType(), makePublic(field.getModifiers()),
+ return new ResolvedMember(Member.FIELD, field.getDeclaringType(),
+ makePublic(field.getModifiers()),
field.getReturnType(),
NameMangler.interFieldClassField(field.getModifiers(), aspectType, field.getDeclaringType(), field.getName()),
TypeX.NONE
@@ -379,7 +389,7 @@ public class AjcMemberMaker {
* is declared onto
*/
public static ResolvedMember interFieldInterfaceField(ResolvedMember field, TypeX onClass, TypeX aspectType) {
- return new ResolvedMember(Member.FIELD, onClass, Modifier.PUBLIC,
+ return new ResolvedMember(Member.FIELD, onClass, makePublic(field.getModifiers()),
field.getReturnType(),
NameMangler.interFieldInterfaceField(aspectType, field.getDeclaringType(), field.getName()),
TypeX.NONE
@@ -461,7 +471,13 @@ public class AjcMemberMaker {
paramTypes = TypeX.insert(meth.getDeclaringType(), paramTypes);
}
- return new ResolvedMember(Member.METHOD, aspectType, PUBLIC_STATIC,
+ int modifiers = PUBLIC_STATIC;
+ if (Modifier.isStrict(meth.getModifiers())) {
+ modifiers |= Modifier.STRICT;
+ }
+
+
+ return new ResolvedMember(Member.METHOD, aspectType, modifiers,
meth.getReturnType(),
NameMangler.interMethodBody(aspectType, meth.getDeclaringType(), meth.getName()),
paramTypes);
diff --git a/weaver/src/org/aspectj/weaver/ResolvedMember.java b/weaver/src/org/aspectj/weaver/ResolvedMember.java
index 1f43ed501..4851f9174 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedMember.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedMember.java
@@ -170,5 +170,9 @@ public class ResolvedMember extends Member implements IHasPosition {
return ResolvedTypeX.isVisible(getModifiers(), getDeclaringType().resolve(world),
fromType);
}
+ public void setCheckedExceptions(TypeX[] checkedExceptions) {
+ this.checkedExceptions = checkedExceptions;
+ }
+
}
diff --git a/weaver/src/org/aspectj/weaver/ResolvedTypeX.java b/weaver/src/org/aspectj/weaver/ResolvedTypeX.java
index 15f5885ed..a2c14f27a 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedTypeX.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedTypeX.java
@@ -931,6 +931,28 @@ public abstract class ResolvedTypeX extends TypeX {
child.getSourceLocation(), parent.getSourceLocation());
return false;
}
+
+ // check declared exceptions
+ ResolvedTypeX[] childExceptions = world.resolve(child.getExceptions());
+ ResolvedTypeX[] parentExceptions = world.resolve(parent.getExceptions());
+ ResolvedTypeX runtimeException = world.resolve("java.lang.RuntimeException");
+ ResolvedTypeX error = world.resolve("java.lang.Error");
+
+ outer: for (int i=0, leni = childExceptions.length; i < leni; i++) {
+ //System.err.println("checking: " + childExceptions[i]);
+ if (runtimeException.isAssignableFrom(childExceptions[i])) continue;
+ if (error.isAssignableFrom(childExceptions[i])) continue;
+
+ for (int j = 0, lenj = parentExceptions.length; j < lenj; j++) {
+ if (parentExceptions[j].isAssignableFrom(childExceptions[i])) continue outer;
+ }
+
+ world.showMessage(IMessage.ERROR, "overriden method doesn't throw "
+ + childExceptions[i].getName(), child.getSourceLocation(), null);
+
+ return false;
+ }
+
return true;
}