Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"abc".split("") get error result ["","a","b","c"] #162

Closed
xiaoxidashen opened this issue Apr 20, 2022 · 1 comment
Closed

"abc".split("") get error result ["","a","b","c"] #162

xiaoxidashen opened this issue Apr 20, 2022 · 1 comment
Labels
bug Something isn't working emulation j2cl Related to the j2cl transpiler

Comments

@xiaoxidashen
Copy link

Describe the bug

"abc".split("") get error array ["","a","b","c"]

To Reproduce

use j2clmavenplugin

//in java MathUtil.java
package cn.util;

import jsinterop.annotations.JsType;

@JsType
public class MathUtil {

    public static native void ppp(String s);

    public static void test() {
        String s = "abc";
        ppp(s);
        String[] split = s.split("");
        ppp("String.valueOf(split)"+"["+String.valueOf(split)+"]");
        ppp("split.length "+split.length+"");
        for (String s1 : split) {
            ppp("["+s1+"]");
        }
    }
}
//MathUtil.native.js
setTimeout(function() {

    MathUtil.ppp = function (s) {
        console.log(s);
    }

    MathUtil.test();

}, 0);

get result in browser console

abc
String.valueOf(split)[,a,b,c]
split.length 4
[]
[a]
[b]
[c]

"abc".split("") The expected result is ["a","b","c"]

@niloc132
Copy link
Member

It looks like this is an upstream error, we're going to close this for now, unless we decide it is necessary to patch this in our j2cl fork. Before creating a PR at https://github.com/Vertispan/j2cl, please try to resolve this at google/j2cl.

google/j2cl#143

@niloc132 niloc132 added bug Something isn't working j2cl Related to the j2cl transpiler emulation labels Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working emulation j2cl Related to the j2cl transpiler
Projects
None yet
Development

No branches or pull requests

2 participants