question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compile error: String concatentation

See original GitHub issue

Compiling the class below throws an exception

public class HelloWorld {
    
    public static String hello(String arg1, String arg2) {
        return arg1 + arg2;
    }
}
Exception in thread "main" java.lang.IndexOutOfBoundsException
        at org.objectweb.asm.tree.InsnList.get(InsnList.java:94)
        at io.neow3j.compiler.NeoMethod.convert(NeoMethod.java:486)
        at io.neow3j.compiler.converters.MethodsConverter.handleUncachedMethodCall(MethodsConverter.java:193)
        at io.neow3j.compiler.converters.MethodsConverter.handleMethodCall(MethodsConverter.java:167)
        at io.neow3j.compiler.converters.MethodsConverter.handleInvoke(MethodsConverter.java:148)
        at io.neow3j.compiler.converters.MethodsConverter.convert(MethodsConverter.java:81)
        at io.neow3j.compiler.Compiler.handleInsn(Compiler.java:404)
        at io.neow3j.compiler.converters.ObjectsConverter.handleStringConcatenation(ObjectsConverter.java:301)
        at io.neow3j.compiler.converters.ObjectsConverter.handleNew(ObjectsConverter.java:167)
        at io.neow3j.compiler.converters.ObjectsConverter.convert(ObjectsConverter.java:83)
        at io.neow3j.compiler.Compiler.handleInsn(Compiler.java:404)
        at io.neow3j.compiler.NeoMethod.convert(NeoMethod.java:488)
        at io.neow3j.compiler.converters.MethodsConverter.handleUncachedMethodCall(MethodsConverter.java:193)
        at io.neow3j.compiler.converters.MethodsConverter.handleMethodCall(MethodsConverter.java:167)
        at io.neow3j.compiler.converters.MethodsConverter.handleInvoke(MethodsConverter.java:148)
        at io.neow3j.compiler.converters.MethodsConverter.convert(MethodsConverter.java:81)
        at io.neow3j.compiler.Compiler.handleInsn(Compiler.java:404)
        at io.neow3j.compiler.NeoMethod.convert(NeoMethod.java:488)
        at io.neow3j.compiler.converters.MethodsConverter.handleUncachedMethodCall(MethodsConverter.java:193)
        at io.neow3j.compiler.converters.MethodsConverter.handleMethodCall(MethodsConverter.java:167)
        at io.neow3j.compiler.converters.MethodsConverter.handleInvoke(MethodsConverter.java:148)
        at io.neow3j.compiler.converters.MethodsConverter.convert(MethodsConverter.java:81)
        at io.neow3j.compiler.Compiler.handleInsn(Compiler.java:404)
        at io.neow3j.compiler.converters.ObjectsConverter.handleStringConcatenation(ObjectsConverter.java:301)
        at io.neow3j.compiler.converters.ObjectsConverter.handleNew(ObjectsConverter.java:167)
        at io.neow3j.compiler.converters.ObjectsConverter.convert(ObjectsConverter.java:83)
        at io.neow3j.compiler.Compiler.handleInsn(Compiler.java:404)
        at io.neow3j.compiler.NeoMethod.convert(NeoMethod.java:488)
        at io.neow3j.compiler.Compiler.compile(Compiler.java:271)
        at io.neow3j.compiler.Compiler.compile(Compiler.java:240)
        at io.neow3j.examples.contractdevelopment.CompileAndDeploy.main(CompileAndDeploy.java:26)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
ykoitzschcommented, May 24, 2021

That’s good to know, so from now on ill compile my contracts using the gradle task.

openjdk version “11.0.11” 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04) OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

1reaction
ykoitzschcommented, May 19, 2021

Hey @gsmachado that’s great news! Unfortunately I am still running into this issue. I will add the compiled class file to this post @csmuller . I am working with java 11.

StringConcatContract3.class.zip

I also did some more testing, the compile error only happens when I concatenate 2 string variables like in bongoCat2() and bongoCat3().

    public static String bongoCat() {
        return "neowwwwwwwwww" +  "something else";
    }

   /*  public static String bongoCat2(String arg1, String arg2) {
        return arg1 +  arg2;
    } */

    public static String bongoCat3String() {
        String arg1 = "hello";
        String arg2 = "world";
        return arg1 +  arg2;
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Swift Compiler Error: "Expression too complex" on a string ...
My understanding is that the Swift team is working on compiler optimizations ... As a result concatenating strings with interpolation ie using "...
Read more >
How to correct a #VALUE! error in the CONCATENATE function
error with CONCATENATE is when you try to build a string that includes a cell reference that has an error, such as #VALUE!....
Read more >
Compile-time string concatenation | Andrzej's C++ blog
Question: what happens when this program is executed? The program hits what is called static initialization order fiasco: while initializing ...
Read more >
VBA Concatenate Text Strings Together (& - Ampersand)
This is the full procedure to concatenate two cells together using string variables. Sub ConcatenateStrings() Dim StringOne as String Dim ...
Read more >
String concatenation documentation is unclear #664 - GitHub
js. I have no idea how to reproduce your error "TypeError: Array.prototype.concat called on null or undefined". [...].
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found