]> source.dussan.org Git - aspectj.git/commitdiff
fix for Bugzilla Bug 42743: declare soft limitation
authoracolyer <acolyer>
Mon, 14 Mar 2005 02:18:56 +0000 (02:18 +0000)
committeracolyer <acolyer>
Mon, 14 Mar 2005 02:18:56 +0000 (02:18 +0000)
weaver/src/org/aspectj/weaver/Lint.java
weaver/src/org/aspectj/weaver/XlintDefault.properties
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java
weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java

index 6f94f98971fe79d955a1bde4e451bf703e148bc4..5e8f0d0e59de7d8aff66f15a3d078f04a9a1e250 100644 (file)
@@ -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;
        }
index 0de844d38d02b69d8ef4edda7c9f664ec10d9dcd..dc651aa8df28bd156525c6d437ffea69c8c95a6c 100644 (file)
@@ -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
index 009343249f3530150caef34974f8d2e2cb6e346e..ab5be0f71112a55eea92d62fb81594b0505f049e 100644 (file)
@@ -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
index b794c9459197207c30acb43b4c527419366558b5..74e27e2f1862eb0ee6afde022f2173e436454baa 100644 (file)
@@ -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);     
index 2b0ef859d2509283443762f44263b17454c90a8e..126d45e951818dbbd66e772107f8bb93ab952efe 100644 (file)
@@ -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) {