Skip to content

Commit b4ccd1e

Browse files
committed
fix duplicate output
1 parent 88d0e4c commit b4ccd1e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/de/inetsoftware/jwebassembly/api/java/lang/ReplacementForString.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ private static String newFromSubBytes( byte[] bytes, int offset, int length ) {
6868
*/
6969
@Replace( "java/lang/String.<init>([C)V" )
7070
static String newFromChars(char[] value) {
71-
return newFromSubChars( value, 0, value.length ); // for compiler
71+
// does not call the replacement method directly. Else the code will compiled two times.
72+
return new String( value, 0, value.length );
7273
}
7374

7475
/**
7576
* Replacement for new String(char[],int,int)
77+
* If module and name is not set then the original from the replaced method is used.
7678
*/
77-
@Import( name = "newFromSubChars", js = "(value,off,count)=>{" + //
79+
@Import( module = "StringHelper", name = "newFromSubChars", js = "(value,off,count)=>{" + //
7880
"var s='';" + //
7981
"for(var i=off;i<off+count;i++){" + //
8082
"s+=String.fromCharCode(value[i]);" + //

0 commit comments

Comments
 (0)