NoSuchMethodError ByteBuffer.position running on Java 8 in 4.8.63
See original GitHub issueI’m getting a weird error with latest 4.8.63:
Caused by: java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
at nonapi.io.github.classgraph.fileslice.reader.RandomAccessFileReader.read(RandomAccessFileReader.java:93)
at nonapi.io.github.classgraph.fileslice.reader.RandomAccessFileReader.readInt(RandomAccessFileReader.java:158)
at nonapi.io.github.classgraph.fastzipfilereader.LogicalZipFile.readCentralDirectory(LogicalZipFile.java:450)
at nonapi.io.github.classgraph.fastzipfilereader.LogicalZipFile.<init>(LogicalZipFile.java:155)
at nonapi.io.github.classgraph.fastzipfilereader.NestedJarHandler$3.newInstance(NestedJarHandler.java:140)
at nonapi.io.github.classgraph.fastzipfilereader.NestedJarHandler$3.newInstance(NestedJarHandler.java:135)
at nonapi.io.github.classgraph.concurrency.SingletonMap.get(SingletonMap.java:189)
at nonapi.io.github.classgraph.fastzipfilereader.NestedJarHandler$4.newInstance(NestedJarHandler.java:203)
at nonapi.io.github.classgraph.fastzipfilereader.NestedJarHandler$4.newInstance(NestedJarHandler.java:150)
at nonapi.io.github.classgraph.concurrency.SingletonMap.get(SingletonMap.java:189)
at io.github.classgraph.ClasspathElementZip.open(ClasspathElementZip.java:140)
it looks like a binary incompatibility with your compile JDK and my runtime. I’m using 1.8.0-121. my version has
public abstract class Buffer {
public final Buffer position(int newPosition) { ... }
// and
public abstract class ByteBuffer extends Buffer
In Java 9 they changed it to:
public abstract class Buffer {
public Buffer position(int newPosition);
// and
public abstract class ByteBuffer extends Buffer {
@Override
public Buffer position(int newPosition) { ... }
I think you’ll need to do
-dstBuf.position(dstBufStart);
+((Buffer)dstBuf).position(dstBufStart);
in nonapi.io.github.classgraph.fileslice.reader.RandomAccessFileReader#read(long, java.nio.ByteBuffer, int, int)
to make the library Java 8 compatible again.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
ByteBuffer and the Dreaded NoSuchMethodError
When run on Java 1.8, this virtual method call will be resolved to Buffer#position(int) at runtime, whereas on Java 9 and later, it'd...
Read more >Status - Bugs - Eclipse
Installed with Eclipseinstaller, I get the follwoing error on startup eclipse.buildId=4.12.0.I20190605-1800 java.version=1.8.0_222 java.vendor=Oracle ...
Read more >Ask Question - Stack Overflow
Exception in thread "main" java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer · 1. Why can't you use the same jdk of ...
Read more >Avoid ByteBuffer incompatibility when compiling with JDK9+
NoSuchMethodError : java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer This is because the generated byte code includes the static return type of ...
Read more >I get a java.lang.NoSuchMethodError when using a java.nio ...
The problem was triggered by compiling with "openjdk version 11.0.3". Although it was compiled with target Java8, and did run under a 'regular'...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That
-booclasspath
option is funny, if you have an older JDK lying around to get thert.jar
from, might as well just use it to compile 😃 I really agree with this comment.I like learning new weird things in tech, thanks for the discussion 😃
Thanks also, I learned a lot!