-
Bug
-
Resolution: Fixed
-
P3
-
1.2.0
-
1.3
-
generic
-
generic
When bandMasks of createPackedRaster is null, a NullPointerException is thrown.
But when bandMasks does exist with zero element, there is no exception thrown. I think there should be some sort of exception thrown since either case has essentially the same effect.
The following program can be used to illustrate this behaviour.
import java.awt.Point;
import java.awt.image.DataBuffer;
import javax.media.jai.RasterFactory;
class Bug_createPackedRaster_i3__12 {
public static void main(String args[]) {
System.out.println("\nWhen bandMasks is null :");
try {
RasterFactory.createPackedRaster(DataBuffer.TYPE_BYTE, 12, 34,
null, new Point(7,8));
System.out.println("No exception thrown.");
} catch(Exception e) {
System.out.println(e);
}
System.out.println("\nWhen bandMasks has zero element :");
try {
RasterFactory.createPackedRaster(DataBuffer.TYPE_BYTE, 12, 34,
new int[]{}, new Point(7,8));
System.out.println("No exception thrown.");
} catch(Exception e) {
System.out.println(e);
}
}
}
--------------------------
daniel.rice@Eng 1999-01-04
The JAI methods simply call Raster.createPackedRaster with identical
arguments. So Java2D should check for a zero-length bandMasks
parameter.
The test program, modified to use only JDK1.2 classes, is as follows:
import java.awt.Point;
import java.awt.image.DataBuffer;
import java.awt.image.Raster;
class Bug_createPackedRaster_i3__12 {
public static void main(String args[]) {
System.out.println("\nWhen bandMasks is null :");
try {
Raster.createPackedRaster(DataBuffer.TYPE_BYTE, 12, 34,
null, new Point(7,8));
System.out.println("No exception thrown.");
} catch(Exception e) {
System.out.println(e);
}
System.out.println("\nWhen bandMasks has zero element :");
try {
Raster.createPackedRaster(DataBuffer.TYPE_BYTE, 12, 34,
new int[]{}, new Point(7,8));
System.out.println("No exception thrown.");
} catch(Exception e) {
System.out.println(e);
}
}
}