diff --git a/src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java b/src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java index 2eeb60ee..c096fd3f 100644 --- a/src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java +++ b/src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java @@ -23,6 +23,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; @@ -312,7 +313,7 @@ public static ByteBuffer convertImageData(BufferedImage bi) { ByteBuffer buf = ByteBuffer.allocateDirect(pixelData.length); buf.order(ByteOrder.nativeOrder()); buf.put(pixelData); - buf.flip(); + ((Buffer) buf).flip(); return buf; } diff --git a/src/main/resources/versionchanges.txt b/src/main/resources/versionchanges.txt index 190e0991..c8b25932 100644 --- a/src/main/resources/versionchanges.txt +++ b/src/main/resources/versionchanges.txt @@ -163,4 +163,5 @@ Version 4.2.0 (11 August 2018) - Upgrade to Tesseract 4.0.0-beta.4 (fd49206) Version 4.2.1 (11 August 2018) -- Recompile using JDK8 to avoid NoSuchMethodError: Method flip() does not exist in class java.nio.ByteBuffer \ No newline at end of file +- Recompile using JDK8 to avoid NoSuchMethodError: Method flip() does not exist in class java.nio.ByteBuffer +- Use explicit cast for compatibility with covariant return type on JDK 9's ByteBuffer methods, e.g., flip() \ No newline at end of file