mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 10:40:01 +00:00
avoiding even more NoSuchMethod exceptions (#6729)
* avoiding more NoSuchMethod exceptions refs #6657 * avoiding even more NoSuchMethod exceptions refs #6657
This commit is contained in:
@@ -49,9 +49,9 @@ public class ByteBufferUtil {
|
|||||||
* size prefix
|
* size prefix
|
||||||
*/
|
*/
|
||||||
public static ByteBuffer removeSizePrefix(ByteBuffer bb) {
|
public static ByteBuffer removeSizePrefix(ByteBuffer bb) {
|
||||||
ByteBuffer s = bb.duplicate();
|
Buffer s = ((Buffer) bb).duplicate();
|
||||||
((Buffer) s).position(s.position() + SIZE_PREFIX_LENGTH);
|
s.position(s.position() + SIZE_PREFIX_LENGTH);
|
||||||
return s;
|
return (ByteBuffer) s;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1089,10 +1089,10 @@ public class FlatBufferBuilder {
|
|||||||
*/
|
*/
|
||||||
public InputStream sizedInputStream() {
|
public InputStream sizedInputStream() {
|
||||||
finished();
|
finished();
|
||||||
ByteBuffer duplicate = bb.duplicate();
|
Buffer duplicate = ((Buffer) bb).duplicate();
|
||||||
((Buffer) duplicate).position(space);
|
duplicate.position(space);
|
||||||
duplicate.limit(bb.capacity());
|
duplicate.limit(bb.capacity());
|
||||||
return new ByteBufferBackedInputStream(duplicate);
|
return new ByteBufferBackedInputStream((ByteBuffer) duplicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -151,9 +151,9 @@ public class Table {
|
|||||||
protected ByteBuffer __vector_as_bytebuffer(int vector_offset, int elem_size) {
|
protected ByteBuffer __vector_as_bytebuffer(int vector_offset, int elem_size) {
|
||||||
int o = __offset(vector_offset);
|
int o = __offset(vector_offset);
|
||||||
if (o == 0) return null;
|
if (o == 0) return null;
|
||||||
ByteBuffer bb = this.bb.duplicate().order(ByteOrder.LITTLE_ENDIAN);
|
ByteBuffer bb = ((ByteBuffer) (((Buffer) this.bb).duplicate())).order(ByteOrder.LITTLE_ENDIAN);
|
||||||
int vectorstart = __vector(o);
|
int vectorstart = __vector(o);
|
||||||
((Buffer) bb).position(vectorstart);
|
bb.position(vectorstart);
|
||||||
bb.limit(vectorstart + __vector_len(o) * elem_size);
|
bb.limit(vectorstart + __vector_len(o) * elem_size);
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,11 +87,11 @@ public class Utf8Old extends Utf8 {
|
|||||||
public String decodeUtf8(ByteBuffer buffer, int offset, int length) {
|
public String decodeUtf8(ByteBuffer buffer, int offset, int length) {
|
||||||
CharsetDecoder decoder = CACHE.get().decoder;
|
CharsetDecoder decoder = CACHE.get().decoder;
|
||||||
decoder.reset();
|
decoder.reset();
|
||||||
buffer = buffer.duplicate();
|
Buffer b = ((Buffer) buffer).duplicate();
|
||||||
((Buffer) buffer).position(offset);
|
b.position(offset);
|
||||||
buffer.limit(offset + length);
|
b.limit(offset + length);
|
||||||
try {
|
try {
|
||||||
CharBuffer result = decoder.decode(buffer);
|
CharBuffer result = decoder.decode((ByteBuffer) b);
|
||||||
return result.toString();
|
return result.toString();
|
||||||
} catch (CharacterCodingException e) {
|
} catch (CharacterCodingException e) {
|
||||||
throw new IllegalArgumentException("Bad encoding", e);
|
throw new IllegalArgumentException("Bad encoding", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user