From: Hannu Niemistö Date: Wed, 21 Jun 2017 13:23:47 +0000 (+0300) Subject: (refs #7326) Better handling of exceptions in Java->SCL interface X-Git-Tag: v1.31.0~299 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=29a9155f55ac9ccaef1b3fd163e7c4230fcd4d1c;ds=sidebyside (refs #7326) Better handling of exceptions in Java->SCL interface Change-Id: I31573bc72f48d601c7f92faa491e59594eefdf59 --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/ValueFromMethod.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/ValueFromMethod.java index 70160dee2..1c8c6431f 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/ValueFromMethod.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/ValueFromMethod.java @@ -27,8 +27,13 @@ public class ValueFromMethod { Object ret = method.invoke(null, p0); return returnsVoid ? Tuple0.INSTANCE : ret; } catch (ReflectiveOperationException e) { - if (e instanceof InvocationTargetException) - throw new RuntimeException(e.getCause()); + if (e instanceof InvocationTargetException) { + Throwable cause = e.getCause(); + if(cause instanceof RuntimeException) + throw (RuntimeException)cause; + else + throw new RuntimeException(cause); + } throw new RuntimeException(e); } } @@ -66,6 +71,13 @@ public class ValueFromMethod { Object ret = method.invoke(null, p0, p1); return returnsVoid ? Tuple0.INSTANCE : ret; } catch (ReflectiveOperationException e) { + if (e instanceof InvocationTargetException) { + Throwable cause = e.getCause(); + if(cause instanceof RuntimeException) + throw (RuntimeException)cause; + else + throw new RuntimeException(cause); + } throw new RuntimeException(e); } } @@ -103,6 +115,13 @@ public class ValueFromMethod { Object ret = method.invoke(null, p0, p1, p2); return returnsVoid ? Tuple0.INSTANCE : ret; } catch (ReflectiveOperationException e) { + if (e instanceof InvocationTargetException) { + Throwable cause = e.getCause(); + if(cause instanceof RuntimeException) + throw (RuntimeException)cause; + else + throw new RuntimeException(cause); + } throw new RuntimeException(e); } } @@ -140,6 +159,13 @@ public class ValueFromMethod { Object ret = method.invoke(null, p0, p1, p2, p3); return returnsVoid ? Tuple0.INSTANCE : ret; } catch (ReflectiveOperationException e) { + if (e instanceof InvocationTargetException) { + Throwable cause = e.getCause(); + if(cause instanceof RuntimeException) + throw (RuntimeException)cause; + else + throw new RuntimeException(cause); + } throw new RuntimeException(e); } } @@ -178,6 +204,13 @@ public class ValueFromMethod { Object ret = method.invoke(null, ps); return returnsVoid ? Tuple0.INSTANCE : ret; } catch (ReflectiveOperationException e) { + if (e instanceof InvocationTargetException) { + Throwable cause = e.getCause(); + if(cause instanceof RuntimeException) + throw (RuntimeException)cause; + else + throw new RuntimeException(cause); + } throw new RuntimeException(e); } }