diff -r de609e0cdab5 -r a83ae75ebf89 rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Fri Jun 10 05:52:44 2016 +0200 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Fri Jun 10 06:27:01 2016 +0200 @@ -1200,9 +1200,18 @@ case opc_new: { int indx = readUShortArg(byteCodes, i); String ci = jc.getClassName(indx); - emit(smapper, this, "var @1 = new @2;", - smapper.pushA(), accessClass(mangleClassName(ci))); - addReference(ci); + if (DirectlLibraries.isScriptLibrary(ci)) { + int last = ci.lastIndexOf('/'); + emit(smapper, this, "var @1 = new @2", + smapper.pushA(), ci.substring(last + 1) + ); + // no new line + outChanged = false; + } else { + emit(smapper, this, "var @1 = new @2;", + smapper.pushA(), accessClass(mangleClassName(ci))); + addReference(ci); + } i += 2; break; } @@ -1822,15 +1831,25 @@ final String in = mi[0]; String mcn; + final boolean direct = DirectlLibraries.isScriptLibrary(in); + boolean skipThis = false; if (callbacks && ( in.equals("org/apidesign/html/boot/spi/Fn") || in.equals("org/netbeans/html/boot/spi/Fn") )) { mcn = "java_lang_Class"; - } else if (DirectlLibraries.isScriptLibrary(in) && in.endsWith("/Exports")) { - append(mi[1]); - append('('); - mcn = null; + } else if (direct) { + if (in.endsWith("/Exports")) { + append(mi[1]); + append('('); + mcn = null; + } else if (mn.startsWith("cons_")) { + append('('); + mcn = null; + skipThis = true; + } else { + mcn = mangleClassName(in); + } } else { mcn = mangleClassName(in); } @@ -1848,10 +1867,17 @@ addReference(in); } if (numArguments > 0) { - append(vars[0]); + String sep; + if (!skipThis) { + append(vars[0]); + sep = ", "; + } else { + sep = ""; + } for (int j = 1; j < numArguments; ++j) { - append(", "); + append(sep); append(vars[j]); + sep = ", "; } } append(");");