Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152561

Is it allowed to have zero value for count in TIFFField.createArrayForType() for the rationals

XMLWordPrintable

        looking at createArrayForType and TIFFField(TIFFTag tag, int type, int count, Object data):

        the 1st checks if count > 0 (for all types) (b110)
        the 2nd checks if count > 1 for the rationals.

        It seems that the checks should be coherent.

        By the way, looking at
        http://hg.openjdk.java.net/jdk9/client/jdk/rev/bf20dd25a7ac
        - why shouldn't we have check 'count > 0' for the rationals here, as earlier?
        It seems to be more natulal to have the same (zero) minimal array size for all the types.

        The following check in the constructor
            case TIFFTag.TIFF_RATIONAL:
                isDataArrayCorrect = data instanceof long[][]
                    && ((long[][])data).length == count
                    && ((long[][])data)[0].length == 2;
                break;

        could be replaced with

            boolean isDataArrayCorrect = data instanceof long[][]
                    && ((long[][])data).length == count
                    && (count > 0 ? ((long[][])data)[0].length == 2 : true);
                break;

        (or does the zero count have some other drawbacks here?)

        The user now can have zero length count for all the types excepting the rationals.

              jdv Jayathirth D V
              avstepan Alexander Stepanov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: