From fcb16b97f4c2ca11e3f02b5e2b396932764b010d Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 30 Nov 2005 12:11:03 +0000 Subject: More fixes for 116679: now copes with the enclosingSP type that we introduced for 1.5 --- tests/compatibility/Simple.java | 21 ------- tests/compatibility/case1/Simple.java | 21 +++++++ tests/compatibility/case2/A.java | 20 +++++++ tests/compatibility/case2/TrackingErrors.aj | 86 +++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 21 deletions(-) delete mode 100644 tests/compatibility/Simple.java create mode 100644 tests/compatibility/case1/Simple.java create mode 100644 tests/compatibility/case2/A.java create mode 100644 tests/compatibility/case2/TrackingErrors.aj (limited to 'tests/compatibility') diff --git a/tests/compatibility/Simple.java b/tests/compatibility/Simple.java deleted file mode 100644 index 72fec1886..000000000 --- a/tests/compatibility/Simple.java +++ /dev/null @@ -1,21 +0,0 @@ -public class Simple { - public static void main(String []argv) { - new Simple().a(); - } - - public void a() {} -} - -aspect X { - before():execution(* a(..)) { - System.err.println(thisJoinPoint); - System.err.println(thisJoinPointStaticPart); - System.err.println(thisEnclosingJoinPointStaticPart); - } - - before():execution(Simple.new(..)) { - System.err.println(thisJoinPoint); - System.err.println(thisEnclosingJoinPointStaticPart); - System.err.println(thisJoinPointStaticPart); - } -} diff --git a/tests/compatibility/case1/Simple.java b/tests/compatibility/case1/Simple.java new file mode 100644 index 000000000..72fec1886 --- /dev/null +++ b/tests/compatibility/case1/Simple.java @@ -0,0 +1,21 @@ +public class Simple { + public static void main(String []argv) { + new Simple().a(); + } + + public void a() {} +} + +aspect X { + before():execution(* a(..)) { + System.err.println(thisJoinPoint); + System.err.println(thisJoinPointStaticPart); + System.err.println(thisEnclosingJoinPointStaticPart); + } + + before():execution(Simple.new(..)) { + System.err.println(thisJoinPoint); + System.err.println(thisEnclosingJoinPointStaticPart); + System.err.println(thisJoinPointStaticPart); + } +} diff --git a/tests/compatibility/case2/A.java b/tests/compatibility/case2/A.java new file mode 100644 index 000000000..e3acbb4bd --- /dev/null +++ b/tests/compatibility/case2/A.java @@ -0,0 +1,20 @@ +public class A { + public static void main(String []argv) { + try { + new A().foo(); + } catch (Exception e) { + } + } + + public void foo() { + try { + } catch (Exception e) { + } + } +} + + +aspect ComplexSub extends TrackingErrors { + public pointcut errorScope(): within(A); +} + diff --git a/tests/compatibility/case2/TrackingErrors.aj b/tests/compatibility/case2/TrackingErrors.aj new file mode 100644 index 000000000..42659de6c --- /dev/null +++ b/tests/compatibility/case2/TrackingErrors.aj @@ -0,0 +1,86 @@ +import org.aspectj.lang.*; + +import org.aspectj.lang.JoinPoint; + +public abstract aspect TrackingErrors { + + protected abstract pointcut errorScope (); + + private pointcut staticContext () : !this(Object); + private pointcut nonStaticContext (Object obj) : this(obj); + private pointcut caughtThrowable (Throwable th) : handler(Throwable+) + && args(th); + + + + private pointcut excluded () : within(TrackingErrors+); + + before (Throwable th) : caughtThrowable(th) && errorScope() && + !excluded() && staticContext() { + + processStaticTrackingErrors(th,thisJoinPointStaticPart,thisEnclosingJoinPointStaticPart); + } + + before (Throwable th, Object obj) : caughtThrowable(th) && errorScope() + && !excluded() && nonStaticContext(obj) { + + processNonStaticTrackingErrors(th,obj,thisJoinPointStaticPart,thisEnclosingJoinPointStaticPart); + } + + protected void processStaticTrackingErrors (Throwable th, + JoinPoint.StaticPart tjp, JoinPoint.StaticPart ejp) {} + + protected void processNonStaticTrackingErrors (Throwable th, Object obj, + JoinPoint.StaticPart tjp, JoinPoint.StaticPart ejp) {} + + protected String getSourceId (JoinPoint.StaticPart ejp) { + String typeName = + ejp.getSignature().getDeclaringTypeName(); + String name = ejp.getSignature().getName(); + return typeName + "." + name; + } + + protected String getProbeId (JoinPoint.StaticPart tjp) { + String sourceLocation = + tjp.getSourceLocation().toString(); + return sourceLocation; + } + +} +/*public abstract aspect Complex { + + protected abstract pointcut scope (); + + private pointcut staticContext () : !this(Object); + private pointcut nonStaticContext (Object obj) : this(obj); + private pointcut caughtThrowable (Throwable th) : handler(Throwable+) && args(th); + + private pointcut excluded () : within(Complex+); + + before (Throwable th) : caughtThrowable(th) && scope() && !excluded() && staticContext() { + processStaticData(th,thisJoinPointStaticPart,thisEnclosingJoinPointStaticPart); + } + + before (Throwable th, Object obj) : caughtThrowable(th) && scope() && !excluded() && nonStaticContext(obj) { + processNonStaticData(th,obj,thisJoinPointStaticPart,thisEnclosingJoinPointStaticPart); + } + + private void processStaticData (Throwable th, JoinPoint.StaticPart tjp, JoinPoint.StaticPart ejp) { + } + + private void processNonStaticData (Throwable th, Object obj, JoinPoint.StaticPart tjp, JoinPoint.StaticPart ejp) { + } + + protected String getSourceId (JoinPoint.StaticPart ejp) { + String typeName = ejp.getSignature().getDeclaringTypeName(); + String name = ejp.getSignature().getName(); + return typeName + "." + name; + } + + protected String getProbeId (JoinPoint.StaticPart tjp) { + String sourceLocation = String.valueOf(tjp.getSourceLocation().getLine()); + return sourceLocation; + } + +} +*/ -- cgit v1.2.3