Skip to content

Commit

Permalink
Use explicit cast Buffer on ByteBuffer object
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenq committed Aug 12, 2018
1 parent 2aa51f7 commit dbbf82a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/net/sourceforge/tess4j/util/ImageIOHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/versionchanges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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()

0 comments on commit dbbf82a

Please sign in to comment.