summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorKamil Rojewski <kamil.rojewski@gmail.com>2021-08-05 21:25:23 +0200
committerGitHub <noreply@github.com>2021-08-05 12:25:23 -0700
commit6fb2c90d9ef1469312840f80612504f27f03cf00 (patch)
tree122e69923866694e78a031a937cbd13e4068bb8d /java
parenta7b527d9427485c9758a36e1ffdb148ac2b0124a (diff)
downloadflatbuffers-6fb2c90d9ef1469312840f80612504f27f03cf00.tar.gz
flatbuffers-6fb2c90d9ef1469312840f80612504f27f03cf00.tar.bz2
flatbuffers-6fb2c90d9ef1469312840f80612504f27f03cf00.zip
avoiding even more NoSuchMethod exceptions (#6729)
* avoiding more NoSuchMethod exceptions refs #6657 * avoiding even more NoSuchMethod exceptions refs #6657
Diffstat (limited to 'java')
-rw-r--r--java/com/google/flatbuffers/ByteBufferUtil.java6
-rw-r--r--java/com/google/flatbuffers/FlatBufferBuilder.java6
-rw-r--r--java/com/google/flatbuffers/Table.java4
-rw-r--r--java/com/google/flatbuffers/Utf8Old.java8
4 files changed, 12 insertions, 12 deletions
diff --git a/java/com/google/flatbuffers/ByteBufferUtil.java b/java/com/google/flatbuffers/ByteBufferUtil.java
index da86a35c..717d6e1b 100644
--- a/java/com/google/flatbuffers/ByteBufferUtil.java
+++ b/java/com/google/flatbuffers/ByteBufferUtil.java
@@ -49,9 +49,9 @@ public class ByteBufferUtil {
* 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;
}
}
diff --git a/java/com/google/flatbuffers/FlatBufferBuilder.java b/java/com/google/flatbuffers/FlatBufferBuilder.java
index 1e181488..b8c1aa20 100644
--- a/java/com/google/flatbuffers/FlatBufferBuilder.java
+++ b/java/com/google/flatbuffers/FlatBufferBuilder.java
@@ -1089,10 +1089,10 @@ public class FlatBufferBuilder {
*/
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);
}
/**
diff --git a/java/com/google/flatbuffers/Table.java b/java/com/google/flatbuffers/Table.java
index 46fa5704..72fdb0a7 100644
--- a/java/com/google/flatbuffers/Table.java
+++ b/java/com/google/flatbuffers/Table.java
@@ -151,9 +151,9 @@ public class Table {
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;
}
diff --git a/java/com/google/flatbuffers/Utf8Old.java b/java/com/google/flatbuffers/Utf8Old.java
index 64b0cf02..e6d02f8e 100644
--- a/java/com/google/flatbuffers/Utf8Old.java
+++ b/java/com/google/flatbuffers/Utf8Old.java
@@ -87,11 +87,11 @@ public class Utf8Old extends Utf8 {
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);