Re: ByteCodeHelper.MapException issue?
Jeroen Frijters <[email protected]> Wed, 3 Feb 2016 14:41:25 +0000
| Newsgroups | gmane.comp.java.ikvm.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Yves, Unless your C# exception extends java.lang.Exception, it won't be caught. If you want to catch everything you need to catch java.lang.Throwable. Regards, Jeroen > -----Original Message----- > From: Yves Langisch [mailto:[email protected]] > Sent: Wednesday, February 3, 2016 14:45 > To: [email protected] > Subject: [Ikvm-developers] ByteCodeHelper.MapException issue? > > Hi, > > I have a converted Java class which does some threading stuff. My > Callable implementations are in C#, the executing and control logic is > in the converted class. > > I catch exceptions in the Callable implementations as follows: > > ... > catch(java.lang.Exception e) { > log.fatal(String.format("Failure running background task. %s", > e.getMessage()), e); > throw e; > } > … > > It looks like that not all C# exceptions are properly handled in the > converted Java class. The snippet above is converted to C# as follows: > > ... > catch (System.Exception ex) > { > int num = 0; > java.lang.Exception exception2 = > ByteCodeHelper.MapException<java.lang.Exception>(ex, > (ByteCodeHelper.MapFlags) num); > if (exception2 == null) > { > throw; > } > else > { > exception1 = exception2; > goto label_9; > } > } > … > label_9: > java.lang.Exception exception3 = exception1; > SessionBackgroundAction.log.fatal((object) > java.lang.String.format("Failure running background task. %s", (object) > Throwable.instancehelper_getMessage((System.Exception) exception3)), > (System.Exception) exception3); > throw Throwable.__\u003Cunmap\u003E((System.Exception) > exception3); > ... > > When throwing a C# exception in my Callable implementations I expect to > see the fatal log statement which I do not. Depending on the exception, > ByteCodeHelper.MapException returns null for all non-Java exceptions. > > java.lang.Exception exception1 = > ByteCodeHelper.MapException<java.lang.Exception>(new Win32Exception(), > (ByteCodeHelper.MapFlags)0); > —> NULL (NOK) > java.lang.Exception exception2 = > ByteCodeHelper.MapException<java.lang.Exception>(new > java.lang.RuntimeException(), (ByteCodeHelper.MapFlags)0); > —> NOT NULL (OK) > java.lang.Exception exception3 = > ByteCodeHelper.MapException<java.lang.Exception>(new System.Exception(), > (ByteCodeHelper.MapFlags)0); > —> NULL (NOK) > > I expect to see the log statement in all cases. Am i overlooking > anything? > > Best, > Yves > > > > > > > ------------------------------------------------------------------------ > ------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 > _______________________________________________ > Ikvm-developers mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/ikvm-developers ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ Ikvm-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ikvm-developers