aboutsummaryrefslogtreecommitdiffstats
path: root/tests/java5/generics
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-08-16 09:26:05 +0000
committeracolyer <acolyer>2005-08-16 09:26:05 +0000
commite50ee045bb9470a6ff0ac8b84b1dbcff3ab13754 (patch)
tree7858118faf9a0d592157552ee110dce92dc43d81 /tests/java5/generics
parente5c36a2a95ba7f07b1de91fe60db47ff4dda9fdc (diff)
downloadaspectj-e50ee045bb9470a6ff0ac8b84b1dbcff3ab13754.tar.gz
aspectj-e50ee045bb9470a6ff0ac8b84b1dbcff3ab13754.zip
test for declare soft in a generic aspect when using type vars
Diffstat (limited to 'tests/java5/generics')
-rw-r--r--tests/java5/generics/genericaspects/DeclareSoftWithTypeVars.aj51
1 files changed, 51 insertions, 0 deletions
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<T extends Throwable> {
+
+ 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<IOException>{
+
+ 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