Skip to content

Commit ce8307b

Browse files
authored
Merge pull request #237 from BobHanson/hanson1
// BH 2022.09.15 fix for new Error() failing; just letting
2 parents 8834205 + 709ac7d commit ce8307b

File tree

8 files changed

+17
-5
lines changed

8 files changed

+17
-5
lines changed
690 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220914134307
1+
20220915081800
690 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220914134307
1+
20220915081800
166 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/test/Test_Error.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ public static void main(String[] args) {
1212
* @j2sNative asdlj()
1313
*/
1414
} catch (Throwable e) {
15-
e.printStackTrace();
15+
e.printStackTrace();
16+
boolean b = (e instanceof Error);
17+
System.out.println(b);
1618
}
1719
System.out.println("Test_Error OK");
1820
}

sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// Google closure compiler cannot handle Clazz.new or Clazz.super
99

10-
// BH 2022.09.14 fix for new Error() failing; just letting java.lang.Error subclass Throwable
10+
// BH 2022.09.15 fix for new Error() failing; just letting java.lang.Error subclass Throwable
1111
// BH 2022.09.08 Fix new Test_Inner().getClass().getMethod("testDollar", new Class<?>[] {Test_Abstract_a.class}).getName()
1212
// BH 2022.04.19 TypeError and ResourceError gain printStackTrace$() methods
1313
// BH 2022.03.19 String.valueOf(Double) does not add ".0"
@@ -1340,6 +1340,11 @@ var getClassName = function(obj, fAsClassName) {
13401340
return "Boolean";
13411341
if (obj instanceof Array || obj.__BYTESIZE)
13421342
return "Array";
1343+
if (obj instanceof ReferenceError || obj instanceof TypeError) {
1344+
// note that this is not technically the case.
1345+
// we use this to ensure that try/catch delivers these as java.lang.Error instances
1346+
return "Error";
1347+
}
13431348
var s = obj.toString();
13441349
// "[object Int32Array]"
13451350
if (s.charAt(0) == '[')

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14045,7 +14045,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1404514045

1404614046
// Google closure compiler cannot handle Clazz.new or Clazz.super
1404714047

14048-
// BH 2022.09.14 fix for new Error() failing; just letting java.lang.Error subclass Throwable
14048+
// BH 2022.09.15 fix for new Error() failing; just letting java.lang.Error subclass Throwable
1404914049
// BH 2022.09.08 Fix new Test_Inner().getClass().getMethod("testDollar", new Class<?>[] {Test_Abstract_a.class}).getName()
1405014050
// BH 2022.04.19 TypeError and ResourceError gain printStackTrace$() methods
1405114051
// BH 2022.03.19 String.valueOf(Double) does not add ".0"
@@ -15378,6 +15378,11 @@ var getClassName = function(obj, fAsClassName) {
1537815378
return "Boolean";
1537915379
if (obj instanceof Array || obj.__BYTESIZE)
1538015380
return "Array";
15381+
if (obj instanceof ReferenceError || obj instanceof TypeError) {
15382+
// note that this is not technically the case.
15383+
// we use this to ensure that try/catch delivers these as java.lang.Error instances
15384+
return "Error";
15385+
}
1538115386
var s = obj.toString();
1538215387
// "[object Int32Array]"
1538315388
if (s.charAt(0) == '[')

0 commit comments

Comments
 (0)