From e50ee045bb9470a6ff0ac8b84b1dbcff3ab13754 Mon Sep 17 00:00:00 2001 From: acolyer Date: Tue, 16 Aug 2005 09:26:05 +0000 Subject: [PATCH] test for declare soft in a generic aspect when using type vars --- .../genericaspects/DeclareSoftWithTypeVars.aj | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/java5/generics/genericaspects/DeclareSoftWithTypeVars.aj diff --git a/tests/java5/generics/genericaspects/DeclareSoftWithTypeVars.aj b/tests/java5/generics/genericaspects/DeclareSoftWithTypeVars.aj new file mode 100644 index 000000000..93081b557 --- /dev/null +++ b/tests/java5/generics/genericaspects/DeclareSoftWithTypeVars.aj @@ -0,0 +1,51 @@ +import java.io.*; + +abstract aspect ExceptionHandling { + + protected abstract void onException(T anException); + + protected abstract pointcut inExceptionHandlingScope(); + + declare soft: T : inExceptionHandlingScope(); + + after() throwing (T anException) : inExceptionHandlingScope() { + onException(anException); + } + +} + + +public aspect DeclareSoftWithTypeVars extends ExceptionHandling{ + + protected pointcut inExceptionHandlingScope() : + call(* doIO*(..)); + + protected void onException(IOException ex) { + System.err.println("handled exception: " + ex.getMessage()); + throw new MyDomainException(ex); + } + + public static void main(String[] args) { + C c = new C(); + try { + c.doIO(); + } catch (MyDomainException ex) { + System.err.println("Successfully converted to domain exception"); + } + } + +} + +class C { + + public void doIO() throws IOException { + throw new IOException("io, io, it's off to work we go..."); + } + +} + +class MyDomainException extends RuntimeException { + public MyDomainException(Throwable t) { + super(t); + } +} \ No newline at end of file -- 2.39.5