summaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-03-14 02:18:56 +0000
committeracolyer <acolyer>2005-03-14 02:18:56 +0000
commite29477276db65a7b85c1fac6e31a7dd3229b0302 (patch)
treea44d5ff86550c9bea0d4e28ebe5e6f148315616d /weaver
parent204274dc0529ecbbaa20d72eec49a14ddf4ba34c (diff)
downloadaspectj-e29477276db65a7b85c1fac6e31a7dd3229b0302.tar.gz
aspectj-e29477276db65a7b85c1fac6e31a7dd3229b0302.zip
fix for Bugzilla Bug 42743: declare soft limitation
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/Lint.java3
-rw-r--r--weaver/src/org/aspectj/weaver/XlintDefault.properties3
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelShadow.java42
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java8
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java2
5 files changed, 42 insertions, 16 deletions
diff --git a/weaver/src/org/aspectj/weaver/Lint.java b/weaver/src/org/aspectj/weaver/Lint.java
index 6f94f9897..5e8f0d0e5 100644
--- a/weaver/src/org/aspectj/weaver/Lint.java
+++ b/weaver/src/org/aspectj/weaver/Lint.java
@@ -83,6 +83,9 @@ public class Lint {
public final Kind elementAlreadyAnnotated =
new Kind("elementAlreadyAnnotated","{0} - already has an annotation of type {1}, cannot add a second instance");
+ public final Kind runtimeExceptionNotSoftened =
+ new Kind("runtimeExceptionNotSoftened","{0} will not be softened as it is already a RuntimeException");
+
public Lint(World world) {
this.world = world;
}
diff --git a/weaver/src/org/aspectj/weaver/XlintDefault.properties b/weaver/src/org/aspectj/weaver/XlintDefault.properties
index 0de844d38..dc651aa8d 100644
--- a/weaver/src/org/aspectj/weaver/XlintDefault.properties
+++ b/weaver/src/org/aspectj/weaver/XlintDefault.properties
@@ -22,4 +22,5 @@ enumAsTargetForDecpIgnored = warning
annotationAsTargetForDecpIgnored = warning
adviceDidNotMatch = warning
invalidTargetForAnnotation = warning
-elementAlreadyAnnotated = warning \ No newline at end of file
+elementAlreadyAnnotated = warning
+runtimeExceptionNotSoftened = warning \ No newline at end of file
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
index 009343249..ab5be0f71 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
@@ -1582,32 +1582,44 @@ public class BcelShadow extends Shadow {
// if the shadow is GUARANTEED empty (i.e., there's NOTHING, not even
// a shadow, inside me).
if (getRange().getStart().getNext() == getRange().getEnd()) return;
- InstructionFactory fact = getFactory();
+
+ InstructionFactory fact = getFactory();
InstructionList handler = new InstructionList();
+ InstructionList rtExHandler = new InstructionList();
BcelVar exceptionVar = genTempVar(catchType);
- exceptionVar.appendStore(handler, fact);
-
- // ENH 42743 suggests that we don't soften runtime exceptions.
- // To implement that, would need to add instructions into the handler
- // stream here to test if exceptionVar is an instanceof RuntimeException,
- // and if it is, just re-throw it without softening.
- // (Not yet implemented obviously).
-
+
handler.append(fact.createNew(NameMangler.SOFT_EXCEPTION_TYPE));
handler.append(InstructionFactory.createDup(1));
handler.append(exceptionVar.createLoad(fact));
handler.append(fact.createInvoke(NameMangler.SOFT_EXCEPTION_TYPE, "<init>",
Type.VOID, new Type[] { Type.THROWABLE }, Constants.INVOKESPECIAL)); //??? special
handler.append(InstructionConstants.ATHROW);
- InstructionHandle handlerStart = handler.getStart();
-
- if (isFallsThrough()) {
+
+ // ENH 42737
+ exceptionVar.appendStore(rtExHandler, fact);
+ // aload_1
+ rtExHandler.append(exceptionVar.createLoad(fact));
+ // instanceof class java/lang/RuntimeException
+ rtExHandler.append(fact.createInstanceOf(new ObjectType("java.lang.RuntimeException")));
+ // ifeq go to new SOFT_EXCEPTION_TYPE instruction
+ rtExHandler.append(InstructionFactory.createBranchInstruction(Constants.IFEQ,handler.getStart()));
+ // aload_1
+ rtExHandler.append(exceptionVar.createLoad(fact));
+ // athrow
+ rtExHandler.append(InstructionFactory.ATHROW);
+
+ InstructionHandle handlerStart = rtExHandler.getStart();
+
+ if (isFallsThrough()) {
InstructionHandle jumpTarget = range.getEnd();//handler.append(fact.NOP);
- handler.insert(InstructionFactory.createBranchInstruction(Constants.GOTO, jumpTarget));
+ rtExHandler.insert(InstructionFactory.createBranchInstruction(Constants.GOTO, jumpTarget));
}
- InstructionHandle protectedEnd = handler.getStart();
- range.insert(handler, Range.InsideAfter);
+ rtExHandler.append(handler);
+
+ InstructionHandle protectedEnd = rtExHandler.getStart();
+ range.insert(rtExHandler, Range.InsideAfter);
+
enclosingMethod.addExceptionHandler(range.getStart().getNext(), protectedEnd.getPrev(),
handlerStart, (ObjectType)BcelWorld.makeBcelType(catchType),
// high priority if our args are on the stack
diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java b/weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java
index b794c9459..74e27e2f1 100644
--- a/weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java
+++ b/weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java
@@ -93,6 +93,14 @@ public class DeclareSoft extends Declare {
pointcut = Pointcut.makeMatchesNothing(Pointcut.RESOLVED);
return;
}
+ // ENH 42743 suggests that we don't soften runtime exceptions.
+ if (scope.getWorld().getCoreType(TypeX.RUNTIME_EXCEPTION).isAssignableFrom(excType)) {
+ scope.getWorld().getLint().runtimeExceptionNotSoftened.signal(
+ new String[]{exception.toString()},
+ exception.getSourceLocation(),null);
+ pointcut = Pointcut.makeMatchesNothing(Pointcut.RESOLVED);
+ return;
+ }
}
pointcut = pointcut.resolve(scope);
diff --git a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
index 2b0ef859d..126d45e95 100644
--- a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
@@ -143,6 +143,8 @@ public class SignaturePattern extends PatternNode {
// String n2 = this.getName().maybeGetSimpleName();
// if (n2!=null && !n1.equals(n2)) return false;
+ // FIXME ASC :
+ if (member == null) return false;
ResolvedMember sig = member.resolve(world);
if (sig == null) {