diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java index 7afc44520f9..010f841315b 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -519,6 +519,11 @@ public class TIFFField implements Cloneable { * @throws IllegalArgumentException if type is an unacceptable * data type for the supplied TIFFTag. * @throws IllegalArgumentException if count < 0. + * @throws IllegalArgumentException if count < 1 + * and type is TIFF_RATIONAL or + * TIFF_SRATIONAL. + * @throws IllegalArgumentException if count ≠ 1 + * and type is TIFF_IFD_POINTER. * @throws NullPointerException if data == null. * @throws IllegalArgumentException if data is an instance of * a class incompatible with the specified type. @@ -534,6 +539,14 @@ public class TIFFField implements Cloneable { + " for " + tag.getName() + " tag"); } else if(count < 0) { throw new IllegalArgumentException("count < 0!"); + } else if((type == TIFFTag.TIFF_RATIONAL + || type == TIFFTag.TIFF_SRATIONAL) + && count < 1) { + throw new IllegalArgumentException + ("Type is TIFF_RATIONAL or TIFF_SRATIONAL and count < 1"); + } else if (type == TIFFTag.TIFF_IFD_POINTER && count != 1) { + throw new IllegalArgumentException + ("Type is TIFF_IFD_POINTER count != 1"); } else if(data == null) { throw new NullPointerException("data == null!"); }