diff options
Diffstat (limited to 'luni/src/main/java/java/nio/NIOAccess.java')
-rw-r--r-- | luni/src/main/java/java/nio/NIOAccess.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/luni/src/main/java/java/nio/NIOAccess.java b/luni/src/main/java/java/nio/NIOAccess.java index 361a37f..36c41cf 100644 --- a/luni/src/main/java/java/nio/NIOAccess.java +++ b/luni/src/main/java/java/nio/NIOAccess.java @@ -28,7 +28,7 @@ final class NIOAccess { * different than what the Harmony implementation calls a "base * address." * - * @param Buffer b the Buffer to be queried + * @param b the Buffer to be queried * @return the native pointer to the Buffer's data at its current * position, or 0 if there is none */ @@ -44,7 +44,7 @@ final class NIOAccess { * Returns the underlying Java array containing the data of the * given Buffer, or null if the Buffer is not backed by a Java array. * - * @param Buffer b the Buffer to be queried + * @param b the Buffer to be queried * @return the Java array containing the Buffer's data, or null if * there is none */ @@ -55,13 +55,14 @@ final class NIOAccess { /** * Returns the offset in bytes from the start of the underlying * Java array object containing the data of the given Buffer to - * the actual start of the data. This method is only meaningful if - * getBaseArray() returns non-null. + * the actual start of the data. The start of the data takes into + * account the Buffer's current position. This method is only + * meaningful if getBaseArray() returns non-null. * - * @param Buffer b the Buffer to be queried + * @param b the Buffer to be queried * @return the data offset in bytes to the start of this Buffer's data */ static int getBaseArrayOffset(Buffer b) { - return b.hasArray() ? (b.arrayOffset() << b._elementSizeShift) : 0; + return b.hasArray() ? ((b.arrayOffset() + b.position) << b._elementSizeShift) : 0; } } |