Skip to content

Commit 6b73463

Browse files
committed
Auto stash before merge of "swingjs" and "origin/swingjs"
Fixing global replacement of "new Boolean" with "Boolean.from" in transpiler
1 parent d17aa8b commit 6b73463

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sources/net.sf.j2s.core/src/net/sf/j2s/core/compiler/Java2ScriptCompiler.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ public static void updateJ2SMap(String prjFolder) {
321321

322322
public static void outputJavaScript(ASTScriptVisitor visitor, DependencyASTVisitor dvisitor, CompilationUnit fRoot, String folderPath, Properties props) {
323323
String js = dvisitor.getDependencyScript(visitor.getBuffer());
324+
//js = js + "\n//SwingJS test " + System.currentTimeMillis() + "\n";
324325
String lineBreak = props.getProperty("j2s.compiler.linebreak");
325326
String whiteSpace = props.getProperty("j2s.compiler.whitespace");
326327
String utf8Header = props.getProperty("j2s.compiler.utf8bom");
@@ -357,6 +358,18 @@ public static void outputJavaScript(ASTScriptVisitor visitor, DependencyASTVisit
357358
.replaceAll("finalVars", "v\\$")
358359
.replaceAll("\\.callbacks", "\\.b\\$")
359360
.replaceAll("\\.\\$finals", "\\.f\\$");
361+
362+
//SwingJS 6/15/2017- Trying to replace new Boolean with Boolean.from because
363+
//new Boolean("false") returns true.
364+
//Require implementation of Boolean.from in runtime
365+
//javascript considers any string to be true while java only considers the string "true"
366+
//to be true
367+
//js = js.replaceAll("new\\ Boolean\\ ", "Boolean\\.from");
368+
js = js.replaceAll("new Boolean ", "Boolean.from");
369+
js = js + "\n\\\\Created Boolean.from js" + System.currentTimeMillis() + "\n";
370+
371+
372+
360373
String abbr = props.getProperty("j2s.compiler.abbreviation");
361374
if (abbr != null) {
362375
if (abbr.equals("true")) {

0 commit comments

Comments
 (0)