-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P2
-
Affects Version/s: 21, 25, 26, 27
-
Component/s: client-libs
The specification for java.awt.image.DataBufferUShort does not clearly define the exceptions that may be thrown by several constructors and methods, leading to unspecified behavior.
Constructors
As and example the following constructors do not specify the exceptions they may throw for invalid inputs:
DataBufferUShort(short[][] dataArray, int size)
DataBufferUShort(short[][] dataArray, int size, int[] offsets)
These constructors should explicitly specify that a NullPointerException is thrown when dataArray is null for example.
Additionally, the constructor:
DataBufferUShort(int size, int numBanks)
does not specify the behavior when negative/OutOfBounds values are passed for size or numBanks. It is unclear whether a NegativeArraySizeException or an ArrayIndexOutOfBoundsException is expected in such cases.
Methods
For the following methods:
getElem(...)
getData(...)
setElem(...)
Here's a small standalone case that represents the issue ...
void main() {
DataBufferUShort db = new DataBufferUShort(4, 1);
db.getElem(1, 0);
db.getElem(0, 4);
// similarly setElem(...) and getData(...)
}
Results:
// ArrayIndexOutOfBoundsException is thrown
// ArrayIndexOutOfBoundsException is thrown
Constructors
As and example the following constructors do not specify the exceptions they may throw for invalid inputs:
DataBufferUShort(short[][] dataArray, int size)
DataBufferUShort(short[][] dataArray, int size, int[] offsets)
These constructors should explicitly specify that a NullPointerException is thrown when dataArray is null for example.
Additionally, the constructor:
DataBufferUShort(int size, int numBanks)
does not specify the behavior when negative/OutOfBounds values are passed for size or numBanks. It is unclear whether a NegativeArraySizeException or an ArrayIndexOutOfBoundsException is expected in such cases.
Methods
For the following methods:
getElem(...)
getData(...)
setElem(...)
Here's a small standalone case that represents the issue ...
void main() {
DataBufferUShort db = new DataBufferUShort(4, 1);
db.getElem(1, 0);
db.getElem(0, 4);
// similarly setElem(...) and getData(...)
}
Results:
// ArrayIndexOutOfBoundsException is thrown
// ArrayIndexOutOfBoundsException is thrown
- csr for
-
JDK-8378116 DataBuffer constructors and methods do not specify required exceptions
-
- Draft
-
- relates to
-
JDK-4393297 Doc probs in java.awt.image.DataBufferInt
-
- Open
-
-
JDK-4398379 java.awt.image.DataBufferShort constructor should verify size of array
-
- Open
-
-
JDK-4398381 java.awt.image.DataBufferShort should check for negative size
-
- Open
-
-
JDK-4398388 Doc probs in java.awt.image.DataBufferUShort
-
- Closed
-
- links to
-
Review(master)
openjdk/jdk/29766
(1 links to)