From 126cecd856546ab883bbdc6e47f24d77ce453057 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 12 Jul 2021 16:45:36 -0700 Subject: [PATCH] Protect against java versioning - Cast ByteBuffers to Buffer before calling #rewind or #flip --- src/main/java/com/jozufozu/flywheel/backend/ShaderSources.java | 3 ++- .../com/jozufozu/flywheel/backend/gl/buffer/VecBuffer.java | 3 ++- .../jozufozu/flywheel/backend/instancing/InstanceMaterial.java | 3 ++- src/main/java/com/jozufozu/flywheel/core/QuadConverter.java | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderSources.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderSources.java index 8ceb05d3c..5cd50306f 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderSources.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderSources.java @@ -5,6 +5,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.StringReader; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.FileChannel; @@ -182,7 +183,7 @@ public class ShaderSources implements ISelectiveResourceReloadListener { try { bytebuffer = readToBuffer(is); int i = bytebuffer.position(); - bytebuffer.rewind(); + ((Buffer) bytebuffer).rewind(); return MemoryUtil.memASCII(bytebuffer, i); } catch (IOException e) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/VecBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/VecBuffer.java index 5291cb324..801dab17a 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/VecBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/VecBuffer.java @@ -1,5 +1,6 @@ package com.jozufozu.flywheel.backend.gl.buffer; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -29,7 +30,7 @@ public class VecBuffer { } public VecBuffer rewind() { - internal.rewind(); + ((Buffer) internal).rewind(); return this; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceMaterial.java index 608af6c89..5266a2759 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceMaterial.java @@ -1,5 +1,6 @@ package com.jozufozu.flywheel.backend.instancing; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Arrays; @@ -137,7 +138,7 @@ public class InstanceMaterial { vertices.putFloat(reader.getV(i)); } - vertices.rewind(); + ((Buffer) vertices).rewind(); // return new BufferedModel(GlPrimitive.QUADS, format, vertices, vertexCount); diff --git a/src/main/java/com/jozufozu/flywheel/core/QuadConverter.java b/src/main/java/com/jozufozu/flywheel/core/QuadConverter.java index 1c717bee6..287cf37d5 100644 --- a/src/main/java/com/jozufozu/flywheel/core/QuadConverter.java +++ b/src/main/java/com/jozufozu/flywheel/core/QuadConverter.java @@ -1,5 +1,6 @@ package com.jozufozu.flywheel.core; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.EnumMap; @@ -136,7 +137,7 @@ public class QuadConverter { type.castAndBuffer(indices, i + 2); type.castAndBuffer(indices, i + 3); } - indices.flip(); + ((Buffer) indices).flip(); } private GlBuffer getBuffer(GlNumericType type) {