8149815: Misleading TIFFField#getAsNativeNode spec about native node name "TIFFIFD"
authorbpb
Wed, 25 May 2016 15:48:57 -0700
changeset 38999 035e9ed4af2c
parent 38998 dfdce8bfb10f
child 39000 810f4edc8b50
8149815: Misleading TIFFField#getAsNativeNode spec about native node name "TIFFIFD" Summary: Change the specification verbiage of TIFFField.getAsNativeNode() to reflect the actual behavior. Reviewed-by: prr
jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFFieldNode.java
jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFFieldNode.java	Wed May 25 15:20:45 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFFieldNode.java	Wed May 25 15:48:57 2016 -0700
@@ -38,9 +38,14 @@
  * wherein the child node is procedural rather than buffered.
  */
 public class TIFFFieldNode extends IIOMetadataNode {
+    private static boolean isIFD(TIFFField f) {
+        int type = f.getType();
+        return f.hasDirectory() &&
+            (type == TIFFTag.TIFF_LONG || type == TIFFTag.TIFF_IFD_POINTER);
+    }
+
     private static String getNodeName(TIFFField f) {
-        return (f.hasDirectory() || f.getData() instanceof TIFFDirectory) ?
-            "TIFFIFD" : "TIFFField";
+        return isIFD(f) ? "TIFFIFD" : "TIFFField";
     }
 
     private boolean isIFD;
@@ -52,8 +57,7 @@
     public TIFFFieldNode(TIFFField field) {
         super(getNodeName(field));
 
-        isIFD = field.hasDirectory() ||
-            field.getData() instanceof TIFFDirectory;
+        isIFD = isIFD(field);
 
         this.field = field;
 
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java	Wed May 25 15:20:45 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java	Wed May 25 15:48:57 2016 -0700
@@ -843,10 +843,9 @@
      * Returns the {@code TIFFField} as a node named either
      * <tt>"TIFFField"</tt> or <tt>"TIFFIFD"</tt> as described in the
      * TIFF native image metadata specification. The node will be named
-     * <tt>"TIFFIFD"</tt> if and only if the field's data object is an
-     * instance of {@link TIFFDirectory} or equivalently
-     * {@link TIFFTag#isIFDPointer getTag.isIFDPointer()} returns
-     * {@code true}.
+     * <tt>"TIFFIFD"</tt> if and only if {@link #hasDirectory()} returns
+     * {@code true} and the field's type is either {@link TIFFTag#TIFF_LONG}
+     * or {@link TIFFTag#TIFF_IFD_POINTER}.
      *
      * @return a {@code Node} named <tt>"TIFFField"</tt> or
      * <tt>"TIFFIFD"</tt>.