]> source.dussan.org Git - aspectj.git/commitdiff
synchronization joinpoints: code dump...
authoraclement <aclement>
Thu, 8 Jun 2006 09:54:00 +0000 (09:54 +0000)
committeraclement <aclement>
Thu, 8 Jun 2006 09:54:00 +0000 (09:54 +0000)
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
weaver/src/org/aspectj/weaver/patterns/PatternParser.java

index cf69a6ab01f4343e6f8cd2a92a9b59b4e0617046..07ebbe3a1cbf8223b1c237a7fc5f240674fe0a03 100644 (file)
@@ -845,7 +845,7 @@ public final class LazyMethodGen {
         InstructionHandle end1 = Range.genEnd(body, end);
                 
         ExceptionRange er = 
-               new ExceptionRange(body, BcelWorld.fromBcel(catchType), highPriority);
+               new ExceptionRange(body, (catchType==null?null:BcelWorld.fromBcel(catchType)), highPriority);
         er.associateWithTargets(start1, end1, handlerStart);
     }
 
@@ -853,6 +853,15 @@ public final class LazyMethodGen {
         return accessFlags;
     }
     
+    public int getAccessFlagsWithoutSynchronized() {
+               if (isSynchronized()) return accessFlags -  Modifier.SYNCHRONIZED;
+               return accessFlags;
+    }
+    
+    public boolean isSynchronized() {
+               return (accessFlags & Modifier.SYNCHRONIZED)!=0;
+    }
+    
     public void setAccessFlags(int newFlags) {
        this.accessFlags = newFlags;
     }
@@ -910,9 +919,13 @@ public final class LazyMethodGen {
     
     public MethodGen pack() {
        //killNops();
+       int flags = getAccessFlags();
+       if (enclosingClass.getWorld().isJoinpointSynchronizationEnabled()) {
+           flags = getAccessFlagsWithoutSynchronized();
+       }
         MethodGen gen =
             new MethodGen(
-                getAccessFlags(),
+                flags,
                 getReturnType(),
                 getArgumentTypes(),
                 null, //getArgumentNames(),
index 926e888b2219974ccf43d0800bc826e3bcf9363b..29326a572c7aa532d14ce2b97beee85d552b9fb0 100644 (file)
@@ -309,7 +309,7 @@ public class PatternParser {
 //             IToken possibleTypeVariableToken = tokenSource.peek();
 //             String[] typeVariables = maybeParseSimpleTypeVariableList();
                if (kind.equals("execution") || kind.equals("call") || 
-                                               kind.equals("get") || kind.equals("set")) {
+                       kind.equals("get") || kind.equals("set")) {
                        p = parseKindedPointcut(kind);
                } else if (kind.equals("args")) {
                        p = parseArgsPointcut();
@@ -339,6 +339,8 @@ public class PatternParser {
                        TypePattern typePat = parseTypePattern(false);
                        eat(")");
                        p = new HandlerPointcut(typePat);
+               } else  if (kind.equals("lock") || kind.equals("unlock")) {
+                       p = parseMonitorPointcut(kind);
                } else  if (kind.equals("initialization")) {
                        eat("(");
                        SignaturePattern sig = parseConstructorSignaturePattern();
@@ -620,6 +622,35 @@ public class PatternParser {
                return new KindedPointcut(shadowKind, sig);
        }
        
+       /** Covers the 'lock()' and 'unlock()' pointcuts */
+       private KindedPointcut parseMonitorPointcut(String kind) {
+               eat("(");
+               TypePattern type = TypePattern.ANY;
+               eat(")");
+               
+               if (kind.equals("lock")) {
+                       return new KindedPointcut(Shadow.SynchronizationLock,
+                                   new SignaturePattern(Member.MONITORENTER, ModifiersPattern.ANY, 
+                                               TypePattern.ANY, 
+                                               TypePattern.ANY,
+//                                             type,
+                                               NamePattern.ANY, 
+                                               TypePatternList.ANY, 
+                                               ThrowsPattern.ANY,
+                                               AnnotationTypePattern.ANY));
+               } else {
+                       return new KindedPointcut(Shadow.SynchronizationUnlock,
+                                   new SignaturePattern(Member.MONITORENTER, ModifiersPattern.ANY, 
+                                               TypePattern.ANY, 
+                                               TypePattern.ANY, 
+//                                             type,
+                                               NamePattern.ANY, 
+                                               TypePatternList.ANY, 
+                                               ThrowsPattern.ANY,
+                                               AnnotationTypePattern.ANY));
+               }
+       }
+       
        public TypePattern parseTypePattern() {
                return parseTypePattern(false);
        }