Skip to content

Commit 015558a

Browse files
committed
// BH 2025.01.31 added checks for JavaScript SyntaxError similar to
other Error types
1 parent 1ead8f1 commit 015558a

File tree

5 files changed

+50
-16
lines changed

5 files changed

+50
-16
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20250108230306
1+
20250130183423
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20250108230306
1+
20250130183423
191 Bytes
Binary file not shown.

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

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

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

10+
// BH 2025.01.31 added checks for JavaScript SyntaxError similar to other Error types
1011
// BH 2024.11.23 implementing java.awt.Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval")
1112
// BH 2024.06.22 adds Integer.getIngeger(String, int) (returning null)
1213
// BH 2024.03.03 removes unnecessary loadClass("xxxx") on exceptionOf(e,"xxxx") call
@@ -1360,7 +1361,7 @@ var getClassName = function(obj, fAsClassName) {
13601361
return "Boolean";
13611362
if (obj instanceof Array || obj.__BYTESIZE)
13621363
return "Array";
1363-
if (obj instanceof ReferenceError || obj instanceof TypeError) {
1364+
if (obj instanceof ReferenceError || obj instanceof TypeError || obj instanceof SyntaxError) {
13641365
// note that this is not technically the case.
13651366
// we use this to ensure that try/catch delivers these as java.lang.Error instances
13661367
return "Error";
@@ -7071,14 +7072,30 @@ if(lineNum>=0){
70717072

70727073
TypeError.prototype.getMessage$ || (
70737074

7074-
ReferenceError.prototype.getMessage$ = TypeError.prototype.getMessage$
7075-
= ReferenceError.prototype.getMessage$ = TypeError.prototype.getLocalizedMessage$
7075+
SyntaxError.prototype.getMessage$
7076+
= ReferenceError.prototype.getMessage$
7077+
= TypeError.prototype.getMessage$
7078+
= SyntaxError.prototype.getLocalizedMessage$
7079+
= ReferenceError.prototype.getLocalizedMessage$
7080+
= TypeError.prototype.getLocalizedMessage$
70767081
= function(){ return (this.stack ? this.stack : this.message || this.toString()) + (this.getStackTrace ? this.getStackTrace$() : Clazz._getStackTrace())});
70777082

7078-
TypeError.prototype.getStackTrace$ = ReferenceError.prototype.getStackTrace$ = function() { return Clazz._getStackTrace() }
7079-
TypeError.prototype.printStackTrace$ = ReferenceError.prototype.printStackTrace$ = function() { printStackTrace(this,System.err) }
7080-
ReferenceError.prototype.printStackTrace$java_io_PrintStream = TypeError.prototype.printStackTrace$java_io_PrintStream = function(stream){stream.println$S(this + "\n" + this.stack);};
7081-
ReferenceError.prototype.printStackTrace$java_io_PrintWriter = TypeError.prototype.printStackTrace$java_io_PrintWriter = function(printer){printer.println$S(this + "\n" + this.stack);};
7083+
TypeError.prototype.getStackTrace$
7084+
= SyntaxError.prototype.getStackTrace$
7085+
= ReferenceError.prototype.getStackTrace$
7086+
= function() { return Clazz._getStackTrace() }
7087+
TypeError.prototype.printStackTrace$
7088+
= SyntaxError.prototype.printStackTrace$
7089+
= ReferenceError.prototype.printStackTrace$
7090+
= function() { printStackTrace(this,System.err) }
7091+
ReferenceError.prototype.printStackTrace$java_io_PrintStream
7092+
= TypeError.prototype.printStackTrace$java_io_PrintStream
7093+
= SyntaxError.prototype.printStackTrace$java_io_PrintStream
7094+
= function(stream){stream.println$S(this + "\n" + this.stack);};
7095+
ReferenceError.prototype.printStackTrace$java_io_PrintWriter
7096+
= TypeError.prototype.printStackTrace$java_io_PrintWriter
7097+
= SyntaxError.prototype.printStackTrace$java_io_PrintWriter
7098+
= function(printer){printer.println$S(this + "\n" + this.stack);};
70827099

70837100
Clazz.Error = Error;
70847101

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

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14143,6 +14143,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1414314143

1414414144
// Google closure compiler cannot handle Clazz.new or Clazz.super
1414514145

14146+
// BH 2025.01.31 added checks for JavaScript SyntaxError similar to other Error types
1414614147
// BH 2024.11.23 implementing java.awt.Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval")
1414714148
// BH 2024.06.22 adds Integer.getIngeger(String, int) (returning null)
1414814149
// BH 2024.03.03 removes unnecessary loadClass("xxxx") on exceptionOf(e,"xxxx") call
@@ -15496,7 +15497,7 @@ var getClassName = function(obj, fAsClassName) {
1549615497
return "Boolean";
1549715498
if (obj instanceof Array || obj.__BYTESIZE)
1549815499
return "Array";
15499-
if (obj instanceof ReferenceError || obj instanceof TypeError) {
15500+
if (obj instanceof ReferenceError || obj instanceof TypeError || obj instanceof SyntaxError) {
1550015501
// note that this is not technically the case.
1550115502
// we use this to ensure that try/catch delivers these as java.lang.Error instances
1550215503
return "Error";
@@ -21207,14 +21208,30 @@ if(lineNum>=0){
2120721208

2120821209
TypeError.prototype.getMessage$ || (
2120921210

21210-
ReferenceError.prototype.getMessage$ = TypeError.prototype.getMessage$
21211-
= ReferenceError.prototype.getMessage$ = TypeError.prototype.getLocalizedMessage$
21211+
SyntaxError.prototype.getMessage$
21212+
= ReferenceError.prototype.getMessage$
21213+
= TypeError.prototype.getMessage$
21214+
= SyntaxError.prototype.getLocalizedMessage$
21215+
= ReferenceError.prototype.getLocalizedMessage$
21216+
= TypeError.prototype.getLocalizedMessage$
2121221217
= function(){ return (this.stack ? this.stack : this.message || this.toString()) + (this.getStackTrace ? this.getStackTrace$() : Clazz._getStackTrace())});
2121321218

21214-
TypeError.prototype.getStackTrace$ = ReferenceError.prototype.getStackTrace$ = function() { return Clazz._getStackTrace() }
21215-
TypeError.prototype.printStackTrace$ = ReferenceError.prototype.printStackTrace$ = function() { printStackTrace(this,System.err) }
21216-
ReferenceError.prototype.printStackTrace$java_io_PrintStream = TypeError.prototype.printStackTrace$java_io_PrintStream = function(stream){stream.println$S(this + "\n" + this.stack);};
21217-
ReferenceError.prototype.printStackTrace$java_io_PrintWriter = TypeError.prototype.printStackTrace$java_io_PrintWriter = function(printer){printer.println$S(this + "\n" + this.stack);};
21219+
TypeError.prototype.getStackTrace$
21220+
= SyntaxError.prototype.getStackTrace$
21221+
= ReferenceError.prototype.getStackTrace$
21222+
= function() { return Clazz._getStackTrace() }
21223+
TypeError.prototype.printStackTrace$
21224+
= SyntaxError.prototype.printStackTrace$
21225+
= ReferenceError.prototype.printStackTrace$
21226+
= function() { printStackTrace(this,System.err) }
21227+
ReferenceError.prototype.printStackTrace$java_io_PrintStream
21228+
= TypeError.prototype.printStackTrace$java_io_PrintStream
21229+
= SyntaxError.prototype.printStackTrace$java_io_PrintStream
21230+
= function(stream){stream.println$S(this + "\n" + this.stack);};
21231+
ReferenceError.prototype.printStackTrace$java_io_PrintWriter
21232+
= TypeError.prototype.printStackTrace$java_io_PrintWriter
21233+
= SyntaxError.prototype.printStackTrace$java_io_PrintWriter
21234+
= function(printer){printer.println$S(this + "\n" + this.stack);};
2121821235

2121921236
Clazz.Error = Error;
2122021237

0 commit comments

Comments
 (0)