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

PrintNullString.java doesn't use float arguments

XMLWordPrintable

    • b02

        The java/awt/print/PrinterJob/PrintNullString.java tests Graphics2D.drawString API which accepts int and float as the coordinates, yet in some cases it passes int where it should be float.

        https://github.com/openjdk/jdk/blob/1e04ee6d57d5fe84e1d202b16e8d13dc13c002ff/test/jdk/java/awt/print/PrinterJob/PrintNullString.java#L148-L154

                    // API 3: null & empty drawString(Iterator, int, int);
                    try {
                        g2d.drawString(nullIterator, 20, 120);
                        g2d.drawString("FAILURE: No NPE for null iterator, float", 20, 120);
                    } catch (NullPointerException e) {
                        g2d.drawString("caught expected NPE for null iterator, int", 20, 120);
                    }

        This code has inconsistency: the error message refers to float whereas the call to g2d.drawString uses int and the success message uses int.


        https://github.com/openjdk/jdk/blob/1e04ee6d57d5fe84e1d202b16e8d13dc13c002ff/test/jdk/java/awt/print/PrinterJob/PrintNullString.java#L171-L176
                    try {
                        g2d.drawString(emptyIterator, 20, 180);
                        g2d.drawString("FAILURE: No IAE for empty iterator, float", 20, 180);
                    } catch (IllegalArgumentException e) {
                        g2d.drawString("caught expected IAE for empty iterator, float", 20, 180);
                    }

        This piece of code should use float coordinates but it still uses int.

              rkannathpari Renjith Kannath Pariyangad
              aivanov Alexey Ivanov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: