avoiding NoSuchMethod exception (#6658)

This commit is contained in:
Kamil Rojewski
2021-05-24 20:09:45 +02:00
committed by GitHub
parent d84bccb0c7
commit 813d3632ec
7 changed files with 28 additions and 22 deletions

View File

@@ -31,6 +31,7 @@
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;
@@ -310,7 +311,7 @@ final public class Utf8Safe extends Utf8 {
}
if (inIx == inLength) {
// Successfully encoded the entire string.
out.position(outIx + inIx);
((Buffer) out).position(outIx + inIx);
return;
}
@@ -353,7 +354,7 @@ final public class Utf8Safe extends Utf8 {
}
// Successfully encoded the entire string.
out.position(outIx);
((Buffer) out).position(outIx);
} catch (IndexOutOfBoundsException e) {
// TODO(nathanmittler): Consider making the API throw IndexOutOfBoundsException instead.
@@ -434,7 +435,7 @@ final public class Utf8Safe extends Utf8 {
int start = out.arrayOffset();
int end = encodeUtf8Array(in, out.array(), start + out.position(),
out.remaining());
out.position(end - start);
((Buffer) out).position(end - start);
} else {
encodeUtf8Buffer(in, out);
}