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

@@ -17,6 +17,7 @@
package com.google.flatbuffers;
import java.nio.ByteBuffer;
import java.nio.Buffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.CharsetDecoder;
@@ -87,7 +88,7 @@ public class Utf8Old extends Utf8 {
CharsetDecoder decoder = CACHE.get().decoder;
decoder.reset();
buffer = buffer.duplicate();
buffer.position(offset);
((Buffer) buffer).position(offset);
buffer.limit(offset + length);
try {
CharBuffer result = decoder.decode(buffer);