mirkosertic / Bytecoder

Framework to interpret and transpile JVM bytecode to JavaScript, OpenCL or WebAssembly.
https://www.mirkosertic.de/blog/2017/06/compiling-bytecode-to-javascript/
Apache License 2.0
897 stars 58 forks source link

AnalysisException: No such method : java/lang/String.join #1013

Open TypeSafeSchwalbe opened 5 months ago

TypeSafeSchwalbe commented 5 months ago

I have been trying to get my compiler written in Java to compile to Javascript with Bytecoder, and sadly it fails with the following messages:

May 22, 2024 6:39:59 PM de.mirkosertic.bytecoder.core.Slf4JLogger info
INFO: Compiling main class typesafeschwalbe.gerac.web.WebCompiler to directory ..
Current Analysis Stack is : 
Parsing method body of typesafeschwalbe.gerac.web.WebCompiler.compile
 Parsing method body of typesafeschwalbe.gerac.compiler.Compiler.compile
  Parsing method body of typesafeschwalbe.gerac.compiler.frontend.SourceParser.<init>
   Parsing method body of typesafeschwalbe.gerac.compiler.frontend.Parser.<init>
    Parsing method body of typesafeschwalbe.gerac.compiler.frontend.Parser.next
     Parsing method body of typesafeschwalbe.gerac.compiler.frontend.Lexer.nextToken
      Parsing method body of typesafeschwalbe.gerac.compiler.Error$Marking.error
       Parsing method body of typesafeschwalbe.gerac.compiler.Error$Marking$Type.<clinit>
        Parsing method body of typesafeschwalbe.gerac.compiler.Color.from
          Visiting #2 ALOAD Stack size is 0 Source line 28
          Local 0 of type [Ljava/lang/String;
          Visiting #3 ARRAYLENGTH Stack size is 1 Source line 28
          Local 0 of type [Ljava/lang/String;
          Stack 0 of type [Ljava/lang/String;
          Visiting #4 IFLE Stack size is 1 Source line 28
          Local 0 of type [Ljava/lang/String;
          Stack 0 of type I
          Visiting #5 LDC Stack size is 0 Source line 28
          Local 0 of type [Ljava/lang/String;
          Visiting #6 GOTO Stack size is 1 Source line 28
          Local 0 of type [Ljava/lang/String;
          Stack 0 of type Ljava/lang/String;
          Check of stack size is ok
          Visiting #12 LDC Stack size is 1 Source line 28
          Local 0 of type [Ljava/lang/String;
          Stack 0 of type Ljava/lang/String;
          Visiting #13 ALOAD Stack size is 2 Source line 28
          Local 0 of type [Ljava/lang/String;
          Stack 0 of type Ljava/lang/String;
          Stack 1 of type Ljava/lang/String;
          Visiting #16 INVOKESTATIC Stack size is 3 Source line 29
          Local 0 of type [Ljava/lang/String;
          Stack 0 of type Ljava/lang/String;
          Stack 1 of type Ljava/lang/String;
          Stack 2 of type [Ljava/lang/String;
de.mirkosertic.bytecoder.core.ir.AnalysisException: java.lang.IllegalStateException: No such method : java/lang/String.join(Ljava/lang/CharSequence;[Ljava/lang/CharSequence;)Ljava/lang/String;
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:113)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse_INVOKESTATIC(GraphParser.java:841)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parseMethodInsNode(GraphParser.java:887)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:2656)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:409)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.<init>(GraphParser.java:154)
    at de.mirkosertic.bytecoder.core.ir.ResolvedMethod.parseBody(ResolvedMethod.java:47)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethodInternal(ResolvedClass.java:137)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:111)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse_INVOKESTATIC(GraphParser.java:841)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parseMethodInsNode(GraphParser.java:887)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:2656)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:409)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.<init>(GraphParser.java:154)
    at de.mirkosertic.bytecoder.core.ir.ResolvedMethod.parseBody(ResolvedMethod.java:47)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethodInternal(ResolvedClass.java:137)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:111)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.requestInitialization(ResolvedClass.java:99)
    at de.mirkosertic.bytecoder.core.parser.CompileUnit.resolveClass(CompileUnit.java:147)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse_GETSTATICFIELD(GraphParser.java:2161)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parseFieldInsnNode(GraphParser.java:2247)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:2670)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:409)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.<init>(GraphParser.java:154)
    at de.mirkosertic.bytecoder.core.ir.ResolvedMethod.parseBody(ResolvedMethod.java:47)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethodInternal(ResolvedClass.java:137)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:111)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse_INVOKESTATIC(GraphParser.java:841)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parseMethodInsNode(GraphParser.java:887)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:2656)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:409)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.<init>(GraphParser.java:154)
    at de.mirkosertic.bytecoder.core.ir.ResolvedMethod.parseBody(ResolvedMethod.java:47)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethodInternal(ResolvedClass.java:137)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:111)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse_INVOKEVIRTUAL(GraphParser.java:707)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parseMethodInsNode(GraphParser.java:883)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:2656)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:409)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.<init>(GraphParser.java:154)
    at de.mirkosertic.bytecoder.core.ir.ResolvedMethod.parseBody(ResolvedMethod.java:47)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethodInternal(ResolvedClass.java:137)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:111)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse_INVOKEVIRTUAL(GraphParser.java:689)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parseMethodInsNode(GraphParser.java:883)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:2656)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:409)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.<init>(GraphParser.java:154)
    at de.mirkosertic.bytecoder.core.ir.ResolvedMethod.parseBody(ResolvedMethod.java:47)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethodInternal(ResolvedClass.java:137)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:111)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse_INVOKESPECIAL(GraphParser.java:624)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parseMethodInsNode(GraphParser.java:881)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:2656)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:409)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.<init>(GraphParser.java:154)
    at de.mirkosertic.bytecoder.core.ir.ResolvedMethod.parseBody(ResolvedMethod.java:47)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethodInternal(ResolvedClass.java:137)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:111)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse_INVOKESPECIAL(GraphParser.java:624)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parseMethodInsNode(GraphParser.java:881)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:2656)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:409)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.<init>(GraphParser.java:154)
    at de.mirkosertic.bytecoder.core.ir.ResolvedMethod.parseBody(ResolvedMethod.java:47)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethodInternal(ResolvedClass.java:137)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:111)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse_INVOKESTATIC(GraphParser.java:841)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parseMethodInsNode(GraphParser.java:887)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:2656)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.parse(GraphParser.java:409)
    at de.mirkosertic.bytecoder.core.parser.GraphParser.<init>(GraphParser.java:154)
    at de.mirkosertic.bytecoder.core.ir.ResolvedMethod.parseBody(ResolvedMethod.java:47)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethodInternal(ResolvedClass.java:137)
    at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:111)
    at de.mirkosertic.bytecoder.core.parser.CompileUnit.resolveClass(CompileUnit.java:142)
    at de.mirkosertic.bytecoder.core.parser.CompileUnit.resolveMainMethod(CompileUnit.java:222)
    at de.mirkosertic.bytecoder.cli.CompileJSCommand.call(CompileJSCommand.java:88)
    at de.mirkosertic.bytecoder.cli.CompileJSCommand.call(CompileJSCommand.java:42)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
    at picocli.CommandLine.execute(CommandLine.java:2170)
    at de.mirkosertic.bytecoder.cli.BytecoderCLI.main(BytecoderCLI.java:24)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: java.lang.IllegalStateException: No such method : java/lang/String.join(Ljava/lang/CharSequence;[Ljava/lang/CharSequence;)Ljava/lang/String;
    ... 96 more

Updated to the latest version available on Maven (2024-05-10), didn't solve the issue either :/ Am I doing something wrong (maybe I need to include another jar file?) or is this just not supported at the moment (replacing the usage of String.join with a few calls to a StringBuilder solves that specific error, but spawns the next about Character.charValue missing instead)?

Thanks in advance :)

TypeSafeSchwalbe commented 5 months ago

I guess I should also include that: