Name: rmT116609 Date: 11/21/2002
FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
DirectByteBuffer.put(ByteBuffer src) throws java.nio.ReadOnlyBufferException when the SRC parameter is a Read only ByteBuffer and NOT DirectByteBuffer
This is happend because the put method makes a call to the src.array() method without checking if its a ReadOnlyBuffer
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See code provided
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected: Not to throw exception
Result: Throw java.nio.ReadOnlyBufferException
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.nio.ReadOnlyBufferException
at java.nio.ByteBuffer.array(ByteBuffer.java:900)
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:277)
at DirectByteBufferPutTest.main(DirectByteBufferPutTest.java:10)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.nio.*;
public class DirectByteBufferPutTest {
public static void main (String[] args) {
ByteBuffer bufferA = ByteBuffer.allocate(10);
ByteBuffer bufferB = ByteBuffer.allocateDirect(10);
bufferA.putInt(10);
ByteBuffer readOnly = bufferA.asReadOnlyBuffer();
bufferB.put(readOnly);
}
}
---------- END SOURCE ----------
Release Regression From : 1.4.0_03
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 167271)
======================================================================