summaryrefslogtreecommitdiffstats
path: root/nio
diff options
context:
space:
mode:
Diffstat (limited to 'nio')
-rw-r--r--nio/src/main/java/java/nio/Buffer.java10
-rw-r--r--nio/src/main/java/java/nio/CharToByteBufferAdapter.java6
-rw-r--r--nio/src/main/java/java/nio/DirectByteBuffer.java6
-rw-r--r--nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java6
-rw-r--r--nio/src/main/java/java/nio/FloatToByteBufferAdapter.java6
-rw-r--r--nio/src/main/java/java/nio/IntToByteBufferAdapter.java6
-rw-r--r--nio/src/main/java/java/nio/LongToByteBufferAdapter.java6
-rw-r--r--nio/src/main/java/java/nio/MappedByteBufferAdapter.java6
-rw-r--r--nio/src/main/java/java/nio/ShortToByteBufferAdapter.java6
9 files changed, 50 insertions, 8 deletions
diff --git a/nio/src/main/java/java/nio/Buffer.java b/nio/src/main/java/java/nio/Buffer.java
index 9e870e4..19d8969 100644
--- a/nio/src/main/java/java/nio/Buffer.java
+++ b/nio/src/main/java/java/nio/Buffer.java
@@ -111,6 +111,16 @@ public abstract class Buffer {
int _arrayOffset() {
return 0;
}
+
+ /**
+ * For direct buffers, the effective address of the data. This is set
+ * on first use. If the field is zero, this is either not a direct
+ * buffer or the field has not been initialized, and you need to issue
+ * the getEffectiveAddress() call and use the result of that.
+ *
+ * This is strictly an optimization.
+ */
+ int effectiveDirectAddress = 0;
// END android-added
/**
diff --git a/nio/src/main/java/java/nio/CharToByteBufferAdapter.java b/nio/src/main/java/java/nio/CharToByteBufferAdapter.java
index 14a48ff..bd340be 100644
--- a/nio/src/main/java/java/nio/CharToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/CharToByteBufferAdapter.java
@@ -65,7 +65,11 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer {
public PlatformAddress getEffectiveAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ // BEGIN android-changed
+ PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ effectiveDirectAddress = addr.toInt();
+ return addr;
+ // END android-changed
} else {
assert false : byteBuffer;
return null;
diff --git a/nio/src/main/java/java/nio/DirectByteBuffer.java b/nio/src/main/java/java/nio/DirectByteBuffer.java
index 46529a5..dcdb3c1 100644
--- a/nio/src/main/java/java/nio/DirectByteBuffer.java
+++ b/nio/src/main/java/java/nio/DirectByteBuffer.java
@@ -247,7 +247,11 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer {
* previously.
*/
public final PlatformAddress getEffectiveAddress() {
- return getBaseAddress().offsetBytes(offset);
+ // BEGIN android-changed
+ PlatformAddress addr = getBaseAddress().offsetBytes(offset);
+ effectiveDirectAddress = addr.toInt();
+ return addr;
+ // END android-changed
}
/**
diff --git a/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java b/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java
index 336488b..70406ba 100644
--- a/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java
@@ -65,7 +65,11 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff
public PlatformAddress getEffectiveAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ // BEGIN android-changed
+ PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ effectiveDirectAddress = addr.toInt();
+ return addr;
+ // END android-changed
} else {
assert false : byteBuffer;
return null;
diff --git a/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java b/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java
index 97c0528..75b9d84 100644
--- a/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java
@@ -65,7 +65,11 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer
public PlatformAddress getEffectiveAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ // BEGIN android-changed
+ PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ effectiveDirectAddress = addr.toInt();
+ return addr;
+ // END android-changed
} else {
assert false : byteBuffer;
return null;
diff --git a/nio/src/main/java/java/nio/IntToByteBufferAdapter.java b/nio/src/main/java/java/nio/IntToByteBufferAdapter.java
index 91b9311..e77bec6 100644
--- a/nio/src/main/java/java/nio/IntToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/IntToByteBufferAdapter.java
@@ -65,7 +65,11 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer {
public PlatformAddress getEffectiveAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ // BEGIN android-changed
+ PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ effectiveDirectAddress = addr.toInt();
+ return addr;
+ // END android-changed
} else {
assert false : byteBuffer;
return null;
diff --git a/nio/src/main/java/java/nio/LongToByteBufferAdapter.java b/nio/src/main/java/java/nio/LongToByteBufferAdapter.java
index 0bd3ce4..bcdeb2b 100644
--- a/nio/src/main/java/java/nio/LongToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/LongToByteBufferAdapter.java
@@ -65,7 +65,11 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer {
public PlatformAddress getEffectiveAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ // BEGIN android-changed
+ PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ effectiveDirectAddress = addr.toInt();
+ return addr;
+ // END android-changed
} else {
assert false : byteBuffer;
return null;
diff --git a/nio/src/main/java/java/nio/MappedByteBufferAdapter.java b/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
index 83a51c1..84866dc 100644
--- a/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/MappedByteBufferAdapter.java
@@ -148,7 +148,11 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu
}
public PlatformAddress getEffectiveAddress() {
- return ((DirectBuffer) this.wrapped).getEffectiveAddress();
+ // BEGIN android-changed
+ PlatformAddress addr = ((DirectBuffer) this.wrapped).getEffectiveAddress();
+ effectiveDirectAddress = addr.toInt();
+ return addr;
+ // END android-changed
}
public float getFloat() {
diff --git a/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java b/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java
index 41ce50c..a608bc9 100644
--- a/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java
+++ b/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java
@@ -65,7 +65,11 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer
public PlatformAddress getEffectiveAddress() {
if (byteBuffer instanceof DirectBuffer) {
- return ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ // BEGIN android-changed
+ PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress();
+ effectiveDirectAddress = addr.toInt();
+ return addr;
+ // END android-changed
} else {
assert false : byteBuffer;
return null;