diff options
author | aclement <aclement> | 2006-06-08 09:54:00 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-06-08 09:54:00 +0000 |
commit | d73b7fedff37cb3c892b4fd4b48427111f569f6f (patch) | |
tree | 0c1d9862b22f5be9606a13df431e230bc99253b7 | |
parent | 65ff490a29f85cf4f3fc910e08ab5da8b7065040 (diff) | |
download | aspectj-d73b7fedff37cb3c892b4fd4b48427111f569f6f.tar.gz aspectj-d73b7fedff37cb3c892b4fd4b48427111f569f6f.zip |
synchronization joinpoints: code dump...
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java | 17 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/patterns/PatternParser.java | 33 |
2 files changed, 47 insertions, 3 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java index cf69a6ab0..07ebbe3a1 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -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(), diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java index 926e888b2..29326a572 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java @@ -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); } |