diff options
author | jhugunin <jhugunin> | 2002-12-24 00:34:36 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2002-12-24 00:34:36 +0000 |
commit | 045686fb7995a6eb490cc3d81b30a4b1834b6568 (patch) | |
tree | cee22fcd30b6f60e1fc9f6d63c7767396977f419 /weaver | |
parent | d3156f737f3bb24e3ad695205da5977bef519275 (diff) | |
download | aspectj-045686fb7995a6eb490cc3d81b30a4b1834b6568.tar.gz aspectj-045686fb7995a6eb490cc3d81b30a4b1834b6568.zip |
correctly handling exceptions thrown from intro methods
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/AjcMemberMaker.java | 22 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/ResolvedMember.java | 4 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/ResolvedTypeX.java | 22 |
3 files changed, 45 insertions, 3 deletions
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; } |