FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Server VM (build 1.5.0_01-b08, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux xxx 2.4.20-24.8smp #1 SMP Mon Dec 1 13:19:19 EST 2003 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
If a bulk CharBuffer.put(CharBuffer) is attempted from a wrapped CharSequence into a CharBuffer view of a direct ByteBuffer, a NullPointerException is thrown:
Exception in thread "main" java.lang.NullPointerException
at java.nio.DirectCharBufferS.put(DirectCharBufferS.java:305)
at java.nio.DirectCharBufferS.put(DirectCharBufferS.java:290)
at StringWrapBug.main(StringWrapBug.java:10)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was expecting the program to exit successfully without producing any output.
ACTUAL -
The program threw a NullPointerException.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NullPointerException
at java.nio.DirectCharBufferS.put(DirectCharBufferS.java:305)
at java.nio.DirectCharBufferS.put(DirectCharBufferS.java:290)
at StringWrapBug.main(StringWrapBug.java:10)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.nio.*;
public class StringWrapBug
{
public static void main(final String[] args)
{
try {
final CharBuffer source = CharBuffer.wrap("data");
final ByteBuffer dest = ByteBuffer.allocateDirect(8);
dest.asCharBuffer().put(source);
}
catch (final UnsupportedOperationException xx) {
// CharBuffer.put(CharBuffer) is an optional operation,
// so this is allowed
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Catch both UnsupportedOperationException and NullPointerException when calling the optional CharBuffer.put(CharBuffer) method, and treat them identically.
###@###.### 2005-03-01 11:38:08 GMT
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Server VM (build 1.5.0_01-b08, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux xxx 2.4.20-24.8smp #1 SMP Mon Dec 1 13:19:19 EST 2003 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
If a bulk CharBuffer.put(CharBuffer) is attempted from a wrapped CharSequence into a CharBuffer view of a direct ByteBuffer, a NullPointerException is thrown:
Exception in thread "main" java.lang.NullPointerException
at java.nio.DirectCharBufferS.put(DirectCharBufferS.java:305)
at java.nio.DirectCharBufferS.put(DirectCharBufferS.java:290)
at StringWrapBug.main(StringWrapBug.java:10)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was expecting the program to exit successfully without producing any output.
ACTUAL -
The program threw a NullPointerException.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NullPointerException
at java.nio.DirectCharBufferS.put(DirectCharBufferS.java:305)
at java.nio.DirectCharBufferS.put(DirectCharBufferS.java:290)
at StringWrapBug.main(StringWrapBug.java:10)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.nio.*;
public class StringWrapBug
{
public static void main(final String[] args)
{
try {
final CharBuffer source = CharBuffer.wrap("data");
final ByteBuffer dest = ByteBuffer.allocateDirect(8);
dest.asCharBuffer().put(source);
}
catch (final UnsupportedOperationException xx) {
// CharBuffer.put(CharBuffer) is an optional operation,
// so this is allowed
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Catch both UnsupportedOperationException and NullPointerException when calling the optional CharBuffer.put(CharBuffer) method, and treat them identically.
###@###.### 2005-03-01 11:38:08 GMT