diff --git a/src/main/java/java/nio/Buffer.java b/src/main/java/java/nio/Buffer.java
index 64edb08b..5446e4e0 100644
--- a/src/main/java/java/nio/Buffer.java
+++ b/src/main/java/java/nio/Buffer.java
@@ -86,7 +86,7 @@ public final int capacity () {
*
* @return this buffer.
*/
- public final Buffer clear () {
+ public Buffer clear() {
position = 0;
mark = UNSET_MARK;
limit = capacity;
@@ -100,7 +100,7 @@ public final Buffer clear () {
*
* @return this buffer.
*/
- public final Buffer flip () {
+ public Buffer flip() {
limit = position;
position = 0;
mark = UNSET_MARK;
@@ -139,7 +139,7 @@ public final int limit () {
* @return this buffer.
* @exception IllegalArgumentException if newLimit
is invalid.
*/
- public final Buffer limit (int newLimit) {
+ public Buffer limit(int newLimit) {
if (newLimit < 0 || newLimit > capacity) {
throw new IllegalArgumentException();
}
@@ -159,7 +159,7 @@ public final Buffer limit (int newLimit) {
*
* @return this buffer.
*/
- public final Buffer mark () {
+ public Buffer mark() {
mark = position;
return this;
}
@@ -179,7 +179,7 @@ public final int position () {
* @return this buffer.
* @exception IllegalArgumentException if newPosition
is invalid.
*/
- public final Buffer position (int newPosition) {
+ public Buffer position(int newPosition) {
if (newPosition < 0 || newPosition > limit) {
throw new IllegalArgumentException();
}
@@ -204,7 +204,7 @@ public final int remaining () {
* @return this buffer.
* @exception InvalidMarkException if the mark is not set.
*/
- public final Buffer reset () {
+ public Buffer reset() {
if (mark == UNSET_MARK) {
throw new InvalidMarkException();
}
@@ -218,7 +218,7 @@ public final Buffer reset () {
*
* @return this buffer.
*/
- public final Buffer rewind () {
+ public Buffer rewind() {
position = 0;
mark = UNSET_MARK;
return this;
diff --git a/src/main/java/java/nio/ByteBuffer.java b/src/main/java/java/nio/ByteBuffer.java
index 38168397..9669524a 100644
--- a/src/main/java/java/nio/ByteBuffer.java
+++ b/src/main/java/java/nio/ByteBuffer.java
@@ -20,6 +20,7 @@
import elemental2.core.ArrayBuffer;
import elemental2.core.ArrayBufferView;
import elemental2.core.Int8Array;
+import jsinterop.base.Js;
import org.gwtproject.nio.HasArrayBufferView;
import org.gwtproject.nio.Numbers;
import org.gwtproject.nio.TypedArrayHelper;
@@ -558,6 +559,41 @@ public int hashCode () {
return hash;
}
+ @Override
+ public ByteBuffer limit(int newLimit) {
+ return Js.uncheckedCast(super.limit(newLimit));
+ }
+
+ @Override
+ public ByteBuffer position(int newPosition) {
+ return Js.uncheckedCast(super.position(newPosition));
+ }
+
+ @Override
+ public ByteBuffer mark() {
+ return Js.uncheckedCast(super.mark());
+ }
+
+ @Override
+ public ByteBuffer reset() {
+ return Js.uncheckedCast(super.reset());
+ }
+
+ @Override
+ public ByteBuffer clear() {
+ return Js.uncheckedCast(super.clear());
+ }
+
+ @Override
+ public ByteBuffer flip() {
+ return Js.uncheckedCast(super.flip());
+ }
+
+ @Override
+ public ByteBuffer rewind() {
+ return Js.uncheckedCast(super.rewind());
+ }
+
/** Returns the byte order used by this buffer when converting bytes from/to other primitive
* types.
*
The default byte order of byte buffer is always {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN} diff --git a/src/main/java/java/nio/FloatBuffer.java b/src/main/java/java/nio/FloatBuffer.java index bb2d2b71..ab6732b7 100644 --- a/src/main/java/java/nio/FloatBuffer.java +++ b/src/main/java/java/nio/FloatBuffer.java @@ -19,6 +19,7 @@ import elemental2.core.ArrayBufferView; import elemental2.core.Float32Array; +import jsinterop.base.Js; /** A buffer of floats. *
@@ -112,6 +113,41 @@ public int compareTo (FloatBuffer otherBuffer) { return remaining() - otherBuffer.remaining(); } + @Override + public FloatBuffer limit(int newLimit) { + return Js.uncheckedCast(super.limit(newLimit)); + } + + @Override + public FloatBuffer position(int newPosition) { + return Js.uncheckedCast(super.position(newPosition)); + } + + @Override + public FloatBuffer mark() { + return Js.uncheckedCast(super.mark()); + } + + @Override + public FloatBuffer reset() { + return Js.uncheckedCast(super.reset()); + } + + @Override + public FloatBuffer clear() { + return Js.uncheckedCast(super.clear()); + } + + @Override + public FloatBuffer flip() { + return Js.uncheckedCast(super.flip()); + } + + @Override + public FloatBuffer rewind() { + return Js.uncheckedCast(super.rewind()); + } + /** Returns a duplicated buffer that shares its content with this buffer. *
The duplicated buffer's position, limit, capacity and mark are the same as this buffer. * The duplicated buffer's read-only property and byte order are same as this buffer too.
diff --git a/src/main/java/java/nio/ShortBuffer.java b/src/main/java/java/nio/ShortBuffer.java index 351dba76..ecd30e3a 100644 --- a/src/main/java/java/nio/ShortBuffer.java +++ b/src/main/java/java/nio/ShortBuffer.java @@ -19,6 +19,7 @@ import elemental2.core.ArrayBufferView; import elemental2.core.Int16Array; +import jsinterop.base.Js; /** A buffer of shorts. *A short buffer can be created in either of the following ways:
@@ -108,6 +109,41 @@ public int compareTo (ShortBuffer otherBuffer) { return remaining() - otherBuffer.remaining(); } + @Override + public ShortBuffer limit(int newLimit) { + return Js.uncheckedCast(super.limit(newLimit)); + } + + @Override + public ShortBuffer position(int newPosition) { + return Js.uncheckedCast(super.position(newPosition)); + } + + @Override + public ShortBuffer mark() { + return Js.uncheckedCast(super.mark()); + } + + @Override + public ShortBuffer reset() { + return Js.uncheckedCast(super.reset()); + } + + @Override + public ShortBuffer clear() { + return Js.uncheckedCast(super.clear()); + } + + @Override + public ShortBuffer flip() { + return Js.uncheckedCast(super.flip()); + } + + @Override + public ShortBuffer rewind() { + return Js.uncheckedCast(super.rewind()); + } + /** Returns a duplicated buffer that shares its content with this buffer. *The duplicated buffer's position, limit, capacity and mark are the same as this buffer. * The duplicated buffer's read-only property and byte order are the same as this buffer's.