Skip to content

Commit

Permalink
avoiding even more NoSuchMethod exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
krojew committed Jul 9, 2021
1 parent c0a1b99 commit d3b571a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions java/com/google/flatbuffers/ByteBufferUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public static int getSizePrefix(ByteBuffer bb) {
* size prefix
*/
public static ByteBuffer removeSizePrefix(ByteBuffer bb) {
ByteBuffer s = bb.duplicate();
((Buffer) s).position(s.position() + SIZE_PREFIX_LENGTH);
return s;
Buffer s = ((Buffer) bb).duplicate();
s.position(s.position() + SIZE_PREFIX_LENGTH);
return (ByteBuffer) s;
}

}
Expand Down
6 changes: 3 additions & 3 deletions java/com/google/flatbuffers/FlatBufferBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1089,10 +1089,10 @@ public byte[] sizedByteArray() {
*/
public InputStream sizedInputStream() {
finished();
ByteBuffer duplicate = bb.duplicate();
((Buffer) duplicate).position(space);
Buffer duplicate = ((Buffer) bb).duplicate();
duplicate.position(space);
duplicate.limit(bb.capacity());
return new ByteBufferBackedInputStream(duplicate);
return new ByteBufferBackedInputStream((ByteBuffer) duplicate);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions java/com/google/flatbuffers/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ protected int __vector(int offset) {
protected ByteBuffer __vector_as_bytebuffer(int vector_offset, int elem_size) {
int o = __offset(vector_offset);
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);
((Buffer) bb).position(vectorstart);
bb.position(vectorstart);
bb.limit(vectorstart + __vector_len(o) * elem_size);
return bb;
}
Expand Down
8 changes: 4 additions & 4 deletions java/com/google/flatbuffers/Utf8Old.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ public void encodeUtf8(CharSequence in, ByteBuffer out) {
public String decodeUtf8(ByteBuffer buffer, int offset, int length) {
CharsetDecoder decoder = CACHE.get().decoder;
decoder.reset();
buffer = buffer.duplicate();
((Buffer) buffer).position(offset);
buffer.limit(offset + length);
Buffer b = ((Buffer) buffer).duplicate();
b.position(offset);
b.limit(offset + length);
try {
CharBuffer result = decoder.decode(buffer);
CharBuffer result = decoder.decode((ByteBuffer) b);
return result.toString();
} catch (CharacterCodingException e) {
throw new IllegalArgumentException("Bad encoding", e);
Expand Down

0 comments on commit d3b571a

Please sign in to comment.