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

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

Open
schwalbe-t opened this issue May 22, 2024 · 2 comments
Open

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

schwalbe-t opened this issue May 22, 2024 · 2 comments

Comments

@schwalbe-t
Copy link

schwalbe-t commented May 22, 2024

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 :)

@schwalbe-t
Copy link
Author

schwalbe-t commented May 22, 2024

@FedericoPonzi
Copy link

FedericoPonzi commented Dec 20, 2024

Similar issue I got:

de.mirkosertic.bytecoder.core.ir.AnalysisException: java.lang.IllegalStateException: No such method : java/lang/invoke/MethodHandles$Lookup.lookupClass()Ljava/lang/Class;

Sample repro:

package bytecodertest;
import java.lang.invoke.MethodHandles;
public class HelloWorld {

    public static void main(String[] args) {
        MethodHandles.Lookup lookup = MethodHandles.lookup();

        // Use the lookupClass() method
        Class<?> lookupClass = lookup.lookupClass();
        System.out.println("The lookup class is: " + lookupClass.getName());
    }
}

compiled with:

javac -source 11 -target 11 HelloWorld.java
java -jar bytecoder-cli-2024-05-10-executable.jar compile js -classpath=. -mainclass=bytecodertest.HelloWorld -builddirectory=.

full trace:

de.mirkosertic.bytecoder.core.ir.AnalysisException: java.lang.IllegalStateException: No such method : java/lang/invoke/MethodHandles$Lookup.lookupClass()Ljava/lang/Class;
	at de.mirkosertic.bytecoder.core.ir.ResolvedClass.resolveMethod(ResolvedClass.java:113)
	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.CompileUnit.resolveMainMethod(CompileUnit.java:223)
	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:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	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/invoke/MethodHandles$Lookup.lookupClass()Ljava/lang/Class;
	... 29 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants