[Java] Avoid casting ByteBuffer to Buffer (#6785)

* Revert "avoiding even more NoSuchMethod exceptions (#6729)"

This reverts commit 6fb2c90d9e.

* Revert "avoiding more NoSuchMethod exceptions (#6671)"

This reverts commit 752c7b576d.

* Revert "avoiding NoSuchMethod exception (#6658)"

This reverts commit 813d3632ec.

* Use Java 8 for Kotlin Linux builds to verify
This commit is contained in:
Björn Harrtell
2021-08-31 00:51:06 +02:00
committed by GitHub
parent b20c4d3aad
commit 0e9d79c355
8 changed files with 34 additions and 40 deletions

View File

@@ -31,7 +31,6 @@
package com.google.flatbuffers;
import java.nio.ByteBuffer;
import java.nio.Buffer;
import static java.lang.Character.MAX_SURROGATE;
import static java.lang.Character.MIN_SUPPLEMENTARY_CODE_POINT;
import static java.lang.Character.MIN_SURROGATE;
@@ -311,7 +310,7 @@ final public class Utf8Safe extends Utf8 {
}
if (inIx == inLength) {
// Successfully encoded the entire string.
((Buffer) out).position(outIx + inIx);
out.position(outIx + inIx);
return;
}
@@ -354,7 +353,7 @@ final public class Utf8Safe extends Utf8 {
}
// Successfully encoded the entire string.
((Buffer) out).position(outIx);
out.position(outIx);
} catch (IndexOutOfBoundsException e) {
// TODO(nathanmittler): Consider making the API throw IndexOutOfBoundsException instead.
@@ -435,7 +434,7 @@ final public class Utf8Safe extends Utf8 {
int start = out.arrayOffset();
int end = encodeUtf8Array(in, out.array(), start + out.position(),
out.remaining());
((Buffer) out).position(end - start);
out.position(end - start);
} else {
encodeUtf8Buffer(in, out);
}