diff options
author | Lajos Molnar <lajos@google.com> | 2014-05-19 17:13:07 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-05-19 17:13:07 +0000 |
commit | 6b9a7d3e754ab5588aee4ae54579cf6838bb7e0c (patch) | |
tree | 74d95e221804852eeaa4918dd6b4d43857cf9f6d /luni | |
parent | 2de26a11390c644f5afda07f2a30a278e3a3543c (diff) | |
parent | e30eaf6894647ecf5e1ec3ec5ac8221e41b4d170 (diff) | |
download | libcore-6b9a7d3e754ab5588aee4ae54579cf6838bb7e0c.zip libcore-6b9a7d3e754ab5588aee4ae54579cf6838bb7e0c.tar.gz libcore-6b9a7d3e754ab5588aee4ae54579cf6838bb7e0c.tar.bz2 |
Merge "DirectByteBuffer: allow 0-size MappedByteBuffers starting at NULL"
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/main/java/java/nio/MemoryBlock.java | 5 | ||||
-rw-r--r-- | luni/src/test/java/libcore/java/nio/BufferTest.java | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/luni/src/main/java/java/nio/MemoryBlock.java b/luni/src/main/java/java/nio/MemoryBlock.java index a619b8d..b62e3c6 100644 --- a/luni/src/main/java/java/nio/MemoryBlock.java +++ b/luni/src/main/java/java/nio/MemoryBlock.java @@ -95,6 +95,7 @@ class MemoryBlock { protected long address; protected final long size; private boolean accessible; + private boolean freed; public static MemoryBlock mmap(FileDescriptor fd, long offset, long size, MapMode mapMode) throws IOException { if (size == 0) { @@ -140,6 +141,7 @@ class MemoryBlock { this.address = address; this.size = size; accessible = true; + freed = false; } // Used to support array/arrayOffset/hasArray for direct buffers. @@ -149,10 +151,11 @@ class MemoryBlock { public void free() { address = 0; + freed = true; } public boolean isFreed() { - return address == 0; + return freed; } public boolean isAccessible() { diff --git a/luni/src/test/java/libcore/java/nio/BufferTest.java b/luni/src/test/java/libcore/java/nio/BufferTest.java index de4e0f1..613c6fa 100644 --- a/luni/src/test/java/libcore/java/nio/BufferTest.java +++ b/luni/src/test/java/libcore/java/nio/BufferTest.java @@ -731,7 +731,7 @@ public class BufferTest extends TestCase { Class<?> c = Class.forName("java.nio.DirectByteBuffer"); Constructor<?> ctor = c.getDeclaredConstructor(long.class, int.class); ctor.setAccessible(true); - ByteBuffer bb = (ByteBuffer) ctor.newInstance(1, 0); + ByteBuffer bb = (ByteBuffer) ctor.newInstance(0, 0); try { bb.array(); |