esaulpaugh / headlong

High-performance Contract ABI and RLP for Ethereum
Apache License 2.0
79 stars 20 forks source link

NoSuchMethodError java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer #29

Closed ksafonov closed 2 years ago

ksafonov commented 2 years ago

Hi, I'm getting java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer; at com.esaulpaugh.headlong.abi.TupleType.decodeObjects(TupleType.java:197) at com.esaulpaugh.headlong.abi.TupleType.decode(TupleType.java:172) at com.esaulpaugh.headlong.abi.Function.decodeCall(Function.java:236) at com.esaulpaugh.headlong.abi.Function.decodeCall(Function.java:218)

when using headlong 5.6.0 from Maven central on Java 1.8.0_45.

If you plan to support Java 8 (as readme says) please consider building using maven.compiler.release=0 (see e.g. https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror/).

esaulpaugh commented 2 years ago

I'm having trouble reproducing the error. https://github.com/esaulpaugh/headlong-cli uses 5.6.0 but as it's currently configured, it isn't producing the error.

It uses <source>8</source> and <target>8</target>. Is that what you're using?

esaulpaugh commented 2 years ago

Nevermind. I am seeing the error now. My tests weren't reaching that line. I do not know why my releases are not compiling correctly. I am using

sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava {
    if (!Jvm.current().getJavaVersion().isCompatibleWith(JavaVersion.VERSION_1_8)) {
        options.compilerArgs.addAll(['--release', '8'])
    }
}

While I figure out why gradle is failing to perform as expected, I will probably release a 5.6.1 compiled with JDK 1.8.

esaulpaugh commented 2 years ago

new release: https://github.com/esaulpaugh/headlong/releases/tag/v5.6.1

ksafonov commented 2 years ago

Thank you!