# HG changeset patch # User bpb # Date 1463691100 25200 # Thu May 19 13:51:40 2016 -0700 # Node ID e980a2ac3df5808d748208bab677ade75cb16787 # Parent 1e72fda414085da2da2aae93afc2a9852675167e 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 diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFFieldNode.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFFieldNode.java --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFFieldNode.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFFieldNode.java @@ -38,11 +38,16 @@ * wherein the child node is procedural rather than buffered. */ public class TIFFFieldNode extends IIOMetadataNode { - private static String getNodeName(TIFFField f) { - return (f.hasDirectory() || f.getData() instanceof TIFFDirectory) ? - "TIFFIFD" : "TIFFField"; + 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 isIFD(f) ? "TIFFIFD" : "TIFFField"; + } + private boolean isIFD; private Boolean isInitialized = Boolean.FALSE; @@ -52,8 +57,7 @@ public TIFFFieldNode(TIFFField field) { super(getNodeName(field)); - isIFD = field.hasDirectory() || - field.getData() instanceof TIFFDirectory; + isIFD = isIFD(field); this.field = field; diff --git a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java --- a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -843,10 +843,9 @@ * Returns the {@code TIFFField} as a node named either * "TIFFField" or "TIFFIFD" as described in the * TIFF native image metadata specification. The node will be named - * "TIFFIFD" 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}. + * "TIFFIFD" 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 "TIFFField" or * "TIFFIFD".