-
Bug
-
Resolution: Fixed
-
P4
-
1.0.2, 1.2.0
-
1.2beta4
-
generic, sparc
-
generic, solaris_2.5
-
Not verified
The documentation for java.io.ByteArrayOutputStream constructor
does not mention NegativeArraySizeException. This exception
is thrown when negative parameter is passed to the constructor.
_______ Specification for ByteArrayOutputStream(int) _______
22.18.4 public ByteArrayOutputStream(int size)
This constructor initializes a newly created ByteArrayOutputStream so that
its internal buffer array has length size. This matters only for reasons
of efficiency; the buffer array is replaced by a larger one whenever necessary
to accommodate additional bytes written to the stream.
_______________________ Example ______________________________________
import java.io.*;
public class bug_tests {
public static void main( String argv[] ) {
try {
ByteArrayOutputStream y1 = new ByteArrayOutputStream(-1); // Create new object
} catch (NegativeArraySizeException e) // Catch the exception
{ System.out.println(" It is expected but non-documented exception:"+e);
}
catch (Exception e)
{
System.out.println(" Unexpected exception:"+e);
}
}
}
_____________________Output__________________________________________
It is expected but non-documented exception:java.lang.NegativeArraySizeException
____________________________________________________________________
does not mention NegativeArraySizeException. This exception
is thrown when negative parameter is passed to the constructor.
_______ Specification for ByteArrayOutputStream(int) _______
22.18.4 public ByteArrayOutputStream(int size)
This constructor initializes a newly created ByteArrayOutputStream so that
its internal buffer array has length size. This matters only for reasons
of efficiency; the buffer array is replaced by a larger one whenever necessary
to accommodate additional bytes written to the stream.
_______________________ Example ______________________________________
import java.io.*;
public class bug_tests {
public static void main( String argv[] ) {
try {
ByteArrayOutputStream y1 = new ByteArrayOutputStream(-1); // Create new object
} catch (NegativeArraySizeException e) // Catch the exception
{ System.out.println(" It is expected but non-documented exception:"+e);
}
catch (Exception e)
{
System.out.println(" Unexpected exception:"+e);
}
}
}
_____________________Output__________________________________________
It is expected but non-documented exception:java.lang.NegativeArraySizeException
____________________________________________________________________
- duplicates
-
JDK-4152820 java.io.CharArrayWriter(negative) throws NegativeArraySizeException
- Closed
- relates to
-
JDK-4127654 Constructors for BufferedOutputStream, etc. can throw NegativeArraySizeException
- Closed
-
JDK-4137768 java.io.PushbackReader with negative or zero length pushback buffer
- Closed