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

最新的greys-1.7.6.5-bin.zip 是用jdk9编译的把?java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer #219

Closed
zhaiyuyong opened this issue Dec 8, 2017 · 4 comments

Comments

@zhaiyuyong
Copy link

zhaiyuyong commented Dec 8, 2017

最新的greys-1.7.6.5-bin.zip 是用jdk9编译的把?
好奇怪,之前好的突然就这样了,改java path也不行

2017-12-08T16:53:47.788+0800	INFO	ga-selector-daemon	stdout	2017-12-08 16:53:47 [ga-selector-daemon] INFO  greys-anatomy - accept new connection, client=java.nio.channels.SocketChannel[connected local=/127.0.0.1:3658 remote=/127.0.0.1:48470]@session[0]

2017-12-08T16:53:47.788+0800	INFO	ga-selector-daemon	stderr	Exception in thread "ga-selector-daemon" 
2017-12-08T16:53:47.788+0800	INFO	ga-selector-daemon	stderr	java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
2017-12-08T16:53:47.789+0800	INFO	ga-selector-daemon	stderr		at com.github.ompc.greys.core.server.GaServer.doRead(GaServer.java:324)
2017-12-08T16:53:47.789+0800	INFO	ga-selector-daemon	stderr		at com.github.ompc.greys.core.server.GaServer.access$200(GaServer.java:105)
2017-12-08T16:53:47.789+0800	INFO	ga-selector-daemon	stderr		at com.github.ompc.greys.core.server.GaServer$4.run(GaServer.java:255)
2017-12-08T16:58:47.983+0800	INFO	ga-session-expire-daemon	stdout	2017-12-08 16:58:47 [ga-session-expire-daemon] INFO  greys-anatomy - session[0] was expired

2017-12-08T16:58:47.986+0800	INFO	ga-session-expire-daemon	stdout	2017-12-08 16:58:47 [ga-session-expire-daemon] INFO  greys-anatomy - session[0] destroyed.
@zhaiyuyong zhaiyuyong changed the title java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer 最新的greys-1.7.6.5-bin.zip 是用jdk9编译的把?java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer Dec 8, 2017
@zhaiyuyong
Copy link
Author

plasma-umass/doppio#497
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.

@oldmanpushcart
Copy link
Owner

oldmanpushcart commented Dec 9, 2017

非常抱歉,我立即解决!!

题外话,这个错误挺有意思,我以为在pom中指定了1.6就会万事大吉,但的确没有考虑过这个场景,学习了!!

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
        </plugins>
    </build>

结论:下次我还是得在本机装一个JDK6,哈哈哈;
个人项目回归测试能力堪忧,大家多给我点宽容吧~一早醒来微博好几个反馈同样问题的,赶紧处理

@oldmanpushcart
Copy link
Owner

搞定了

@zhaiyuyong
Copy link
Author

那个pom只能指定编译出来的class文件
minor version: 0
major version: 50
但是如果用了jdk9对比jdk8变化了的api还是有问题

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