Skip to content

Commit 0d7a437

Browse files
committed
synchronous exception throwing
1 parent fb6ea23 commit 0d7a437

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/javaObject.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ JavaObject::~JavaObject() {
156156

157157
POP_LOCAL_JAVA_FRAME();
158158

159+
if(result->IsNativeError()) {
160+
return ThrowException(result);
161+
}
162+
159163
return scope.Close(result);
160164
}
161165

test/Test.class

-69 Bytes
Binary file not shown.

test/Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public Test() {}
1818
public static String staticMethod() { return "staticMethod called"; }
1919
public static int staticMethod(int i) { return i + 1; }
2020
public static void staticMethodThrows(Exception ex) throws Exception { throw ex; }
21-
public static void staticMethodThrowsNew() throws Exception { throw new Exception("my exception"); }
21+
public void methodThrows(Exception ex) throws Exception { throw ex; }
2222

2323
public static int staticMethodOverload(String a) { return 1; }
2424
public static int staticMethodOverload(int a) { return 2; }

test/java-callStaticMethod-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ exports['Java - Call Static Method'] = nodeunit.testCase({
117117
test.done();
118118
},
119119

120-
"callStaticMethodSync exception thrown from method (new exception)": function(test) {
120+
"callMethodSync exception thrown from method": function(test) {
121+
var ex = java.newInstanceSync("java.lang.Exception", "my exception");
122+
var myTest = java.newInstanceSync("Test");
121123
try {
122-
java.callStaticMethodSync("Test", "staticMethodThrowsNew");
124+
myTest.methodThrowsSync(ex);
123125
test.fail("should throw");
124126
} catch(err) {
125127
test.ok(err.toString().match(/my exception/));

0 commit comments

Comments
 (0)