diff --git a/formats/json/jvmMain/src/kotlinx/serialization/json/internal/CharsetReader.kt b/formats/json/jvmMain/src/kotlinx/serialization/json/internal/CharsetReader.kt index 61fc79109..d7c606bd9 100644 --- a/formats/json/jvmMain/src/kotlinx/serialization/json/internal/CharsetReader.kt +++ b/formats/json/jvmMain/src/kotlinx/serialization/json/internal/CharsetReader.kt @@ -103,7 +103,8 @@ internal class CharsetReader( val remaining = if (position <= limit) limit - position else 0 val bytesRead = inputStream.read(byteBuffer.array(), byteBuffer.arrayOffset() + position, remaining) if (bytesRead < 0) return bytesRead - byteBuffer.position(position + bytesRead) + // Method `position(I)LByteBuffer` does not exist in Java 8. For details, see comment for `flip` in `init` method + (byteBuffer as Buffer).position(position + bytesRead) } finally { (byteBuffer as Buffer).flip() // see the `init` block in this class for the reasoning behind the cast }