From 75e38c51de5581fd8b0f44d0049d7bab54a5e681 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Wed, 21 Aug 2019 13:56:39 +0300 Subject: [PATCH] Add support for some methods in NIO buffers from Java 11 --- .../org/teavm/classlib/java/nio/TBuffer.java | 14 +++---- .../teavm/classlib/java/nio/TByteBuffer.java | 42 +++++++++++++++++++ .../teavm/classlib/java/nio/TCharBuffer.java | 42 +++++++++++++++++++ .../classlib/java/nio/TDoubleBuffer.java | 42 +++++++++++++++++++ .../teavm/classlib/java/nio/TFloatBuffer.java | 42 +++++++++++++++++++ .../teavm/classlib/java/nio/TIntBuffer.java | 42 +++++++++++++++++++ .../teavm/classlib/java/nio/TLongBuffer.java | 42 +++++++++++++++++++ .../teavm/classlib/java/nio/TShortBuffer.java | 42 +++++++++++++++++++ 8 files changed, 301 insertions(+), 7 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/nio/TBuffer.java b/classlib/src/main/java/org/teavm/classlib/java/nio/TBuffer.java index b993960da..63619f7f3 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/nio/TBuffer.java +++ b/classlib/src/main/java/org/teavm/classlib/java/nio/TBuffer.java @@ -34,7 +34,7 @@ public abstract class TBuffer { return position; } - public final TBuffer position(int newPosition) { + public TBuffer position(int newPosition) { if (newPosition < 0 || newPosition > limit) { throw new IllegalArgumentException("New position " + newPosition + " is outside of range [0;" + limit + "]"); @@ -50,7 +50,7 @@ public abstract class TBuffer { return limit; } - public final TBuffer limit(int newLimit) { + public TBuffer limit(int newLimit) { if (newLimit < 0 || newLimit > capacity) { throw new IllegalArgumentException("New limit " + newLimit + " is outside of range [0;" + capacity + "]"); @@ -65,12 +65,12 @@ public abstract class TBuffer { return this; } - public final TBuffer mark() { + public TBuffer mark() { mark = position; return this; } - public final TBuffer reset() { + public TBuffer reset() { if (mark < 0) { throw new TInvalidMarkException(); } @@ -78,21 +78,21 @@ public abstract class TBuffer { return this; } - public final TBuffer clear() { + public TBuffer clear() { position = 0; limit = capacity; mark = -1; return this; } - public final TBuffer flip() { + public TBuffer flip() { limit = position; position = 0; mark = -1; return this; } - public final TBuffer rewind() { + public TBuffer rewind() { mark = -1; position = 0; return this; diff --git a/classlib/src/main/java/org/teavm/classlib/java/nio/TByteBuffer.java b/classlib/src/main/java/org/teavm/classlib/java/nio/TByteBuffer.java index f4cd30b2a..8c89c25f7 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/nio/TByteBuffer.java +++ b/classlib/src/main/java/org/teavm/classlib/java/nio/TByteBuffer.java @@ -256,4 +256,46 @@ public abstract class TByteBuffer extends TBuffer implements TComparable