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

Jogl 2.4 and Java 8 FloatBuffer NoSuchMethodError #33

Closed
ncollier opened this issue Sep 21, 2020 · 2 comments
Closed

Jogl 2.4 and Java 8 FloatBuffer NoSuchMethodError #33

ncollier opened this issue Sep 21, 2020 · 2 comments
Assignees

Comments

@ncollier
Copy link
Member

Jogl 2.4 and Java 8:

caused by: java.lang.NoSuchMethodError: java.nio.FloatBuffer.rewind()Ljava/nio/FloatBuffer;
    at saf.v3d.grid.GridMesh.updateColors(GridMesh.java:119)
    at saf.v3d.grid.GridMesh.update(GridMesh.java:115)
    at saf.v3d.grid.VGridShape.update(VGridShape.java:25)
    at repast.simphony.visualizationOGL2D.ValueLayerDisplayLayer.update(ValueLayerDisplayLayer.java:67)
    at repast.simphony.visualizationOGL2D.DisplayOGL2D.update(DisplayOGL2D.java:402)
    at repast.simphony.visualizationOGL2D.DisplayOGL2D.reshape(DisplayOGL2D.java:589)
    at saf.v3d.Canvas2D.reshape(Canvas2D.java:400)
    at jogamp.opengl.GLDrawableHelper.reshape(GLDrawableHelper.java:751)
    at com.jogamp.opengl.awt.GLJPanel$Updater.display(GLJPanel.java:1442)
    at com.jogamp.opengl.awt.GLJPanel$10.run(GLJPanel.java:1521)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
@ncollier ncollier self-assigned this Sep 21, 2020
@ncollier
Copy link
Member Author

ncollier commented Sep 21, 2020

Good explanation from apache/felix#114

Java 9 introduces overridden methods with covariant return types for the following methods in java.nio.ByteBuffer:

position​(int newPosition)
limit​(int newLimit)
flip​()
clear​()
mark​()
reset​()
rewind​()
In Java 9 they all now return ByteBuffer, whereas the methods they override return Buffer,
resulting in exceptions like this when executing on Java 8 and lower:
java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer
This is because the generated byte code includes the static return type of the method, which is not found on Java 8 and lower because the overloaded methods with covariant return types don't exist (the issue appears even with source and target 8 or lower in compilation parameters).
The solution is to cast ByteBuffer instances to Buffer before calling the method.

ncollier added a commit that referenced this issue Sep 21, 2020
@ncollier
Copy link
Member Author

Potential fix in b044a60. Need etatara to test.

ncollier added a commit to Repast/simphony.application.framework that referenced this issue Sep 21, 2020
Jogl 2.4 and Java 8 FloatBuffer NoSuchMethodError
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

1 participant