[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-dev] Exceptions thrown from finally block
|
Yes, all our code uses Java 1.5 features. We're actually doing our compiling through Maven with the "maven.aspectj.source=1.5" property set.
-----Original Message-----
From: aspectj-dev-bounces@xxxxxxxxxxx [mailto:aspectj-dev-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
Sent: Tuesday, January 22, 2008 12:31 PM
To: AspectJ developer discussions
Subject: Re: [aspectj-dev] Exceptions thrown from finally block
I can recreate this if I specify -1.5 as a compile flag to ajc 1.5.4 -
I assume that is what you were doing to? Without -1.5 it works OK.
I then tried it with the new AspectJ1.6.0 and it works fine, with or
without -1.5 being specified. It looks to have been fixed by moving
from an Eclipse 3.1 compiler base inside AspectJ to an Eclipse 3.3
base.
Andy.
On 22/01/2008, Per Jacobsson <PerJacobsson@xxxxxxxxxxxx> wrote:
>
>
>
>
> Hi,
>
> We're seeing some weird behaviour when compiling some code with the 1.5.4
> version of the AspectJ compiler, both from the command line and through the
> Eclipse plugin. I have this pretty convoluted class:
>
>
>
> public class ExceptionTest
>
> {
>
> public void doSomething()
>
> {
>
> throw new RuntimeException("From doSomething");
>
> }
>
>
>
> public int run()
>
> throws Throwable
>
> {
>
> try {
>
> return 0;
>
> } catch (Throwable t) {
>
> System.out.println("Catch");
>
> throw new RuntimeException("From catch");
>
> } finally {
>
> System.out.println("Finally");
>
> try {
>
> doSomething();
>
> } catch (Throwable t) {
>
> System.out.println("Last catch");
>
> throw new RuntimeException("From catch finally");
>
> }
>
> }
>
> }
>
>
>
> public static void main(String[] arg)
>
> throws Throwable
>
> {
>
> new ExceptionTest().run();
>
> }
>
> }
>
>
>
> Note that there are no aspects being woven into this class. But after just
> compiling with AspectJ it gives the following output:
>
>
>
> Finally
>
> Last catch
>
> Catch
>
> Finally
>
> Last catch
>
> Exception in thread "main" java.lang.RuntimeException: From catch finally
>
> at
> com.eharmony.samplematch.ExceptionTest.run(ExceptionTest.java:24)
>
> at
> com.eharmony.samplematch.ExceptionTest.main(ExceptionTest.java:32)
>
>
>
> So the Exception thrown from the finally block is caught by the earlier
> catch block. With the regular Java compiler, instead I get the expected:
>
>
>
> Finally
>
> Last catch
>
> Exception in thread "main" java.lang.RuntimeException: From catch finally
>
> at
> com.eharmony.samplematch.ExceptionTest.run(ExceptionTest.java:24)
>
> at
> com.eharmony.samplematch.ExceptionTest.main(ExceptionTest.java:32)
>
>
>
> The problem seems to be related to the "return 0" inside the first try
> block. If I move that statement out to the last line of the run() method
> things work fine.
>
>
>
> Any ideas on this? I'd be happy to file a bug if that's the case.
>
> Thanks,
>
> / Per
>
>
>
>
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>
>
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev