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

Method flip()Ljava/nio/ByteBuffer; does not exist in class java.nio.ByteBuffer #497

Open
emarsden opened this issue Jul 12, 2017 · 6 comments

Comments

@emarsden
Copy link

Attempting to run ABCL triggers this error.

Exception in thread "interpreter" java.lang.NoSuchMethodError: Method flip()Ljav
a/nio/ByteBuffer; does not exist in class java.nio.ByteBuffer.                  
        at org.armedbear.lisp.util.DecodingReader.<init>(DecodingReader.java:87)
        at org.armedbear.lisp.Stream.<init>(Stream.java:165)                    
        at org.armedbear.lisp.Stream.<init>(Stream.java:148)                    
        at org.armedbear.lisp.Stream.<init>(Stream.java:175)                    
        at org.armedbear.lisp.Lisp.<clinit>(Lisp.java:2810) 

ABCL is from https://common-lisp.net/project/armedbear/

@jvilk jvilk added the bug label Jul 12, 2017
@jvilk
Copy link
Member

jvilk commented Jul 12, 2017

That's an odd error message. flip() returns a Buffer, not a ByteBuffer. Something must be going wrong before ABCL determines the method to invoke!

@jvilk
Copy link
Member

jvilk commented Jul 12, 2017

ABCL has worked in Doppio before, btw. I remember testing it.

@rototor
Copy link

rototor commented Oct 6, 2017

This problem also happens when you build the software with JDK 9 with target JDK 8, because in JDK9 ByteBuffer.flip() returns a ByteBuffer... It used to return a Buffer in JDK8.

And then you try to run this on JDK8 you get exactly this error.

Java-Workaround: Just cast your ByteBuffer to Buffer before calling flip()... i.e. ((Buffer)byteBuffer).flip(). Then you can compile your project with JDK9 and have it running on JDK8.

Note: This is not really related to this project, I only use pure java. But I found this problem report and thought you might be interested in a workaround for this.

@jvilk
Copy link
Member

jvilk commented Oct 6, 2017

Thanks for the tip; I didn't realized JDK9 had some breaking changes like that! It'd be nice to move to JDK9 someday.

@15characterlimi
Copy link

15characterlimi commented Dec 20, 2017

My understanding is that the "correct" way to generate .class files with JDK 9 javac that can be run under JDK 8 java is to not only pass -target 1.8, but to also to set an appropriate bootclasspath, eg. (if $JAVA8_HOME points to an installation of JDK8): --bootclasspath=${JAVA8_HOME}/jre/lib/rt.jar
(the --bootclasspath option only exists when targeting versions <= 1.8; version 9 and onwards have --system=... instead to point to a runtime image with system modules).

This way, you will also get an error at compilation time (rather than JDK 8 runtime) if your .java code is trying to use any JDK 9 APIs that don't exist in JDK 8 at all.

If you're not doing this, then javac will warn you:
warning: [options] bootstrap class path not set in conjunction with -source 1.8

What javac is trying to tell you with that warning is that the resulting class files might not work under JDK 8's java, because of the above two problems.

@15characterlimi
Copy link

Or, more simply, you could use:
--release 8
instead of -source 1.8 -target 1.8 --bootclasspath=...
See http://openjdk.java.net/jeps/247

monetdb-team pushed a commit to MonetDB/monetdb-java that referenced this issue Jun 12, 2018
tpenguinltg added a commit to tpenguinltg/opsu that referenced this issue Sep 9, 2018
This works around an issue with using JDK9 to build the project.

plasma-umass/doppio#497 (comment)
shimpeko added a commit to bricolages/mys3dump that referenced this issue Mar 31, 2020
XinRoom added a commit to XinRoom/Neo-reGeorg that referenced this issue May 27, 2021
修复当使用jdk9编译的class运行于jdk8时buf.clear()错误的问题  plasma-umass/doppio#497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants