Yves Langisch
2016-02-03 13:45:02 UTC
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
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