Does anyone know how to throw abitrary checked Exception in around?
When I try to write advise which throw arbitrary Exception
It always
show me error message can't throw checked Exception 'xxxx'
Only way to throw exception without error is
Object around()
throws AnException: call(* *(..) throws AnException)
{
throw new AnException();
}
But problem is that it must be written to every Exceptions and even it is
done
it can not be prevent new Exceptions.
Is there any solution for this problem?
If there isn't, I hope aspectj developer make a solution like this.
when
aspecj compiler weaving
suround the advice by try catch block
check
throwable can be thrown by target point cut
if it can be thrown by the
point cut just rethrow it
if not just wrap it with RuntimeException and
throw it.
It may reduce performance but does not brake Java Language Specification
and reduce a lot of works.
It will be not a problem if compiler give
warning about performance penalty Or only some special grammar allow to throw
checked Exceptions(like: Object around() throws * : somePointcut()).
I hope there is some solution already exist but i don't know about it.
Thank you.