JDK-8333360 : PrintNullString.java doesn't use float arguments
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8,11,17,21,23
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-05-31
  • Updated: 2025-04-08
  • Resolved: 2024-06-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 17 JDK 21 JDK 24 JDK 8
11.0.27-oracleFixed 17.0.15-oracleFixed 21.0.7-oracleFixed 24 b02Fixed 8u451Fixed
Related Reports
Relates :  
Relates :  
Description
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.
Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/19540 Date: 2024-06-04 12:07:40 +0000
08-04-2025

Fix request [21u,17u] I backport this for parity with 21.0.7-oracle,17.0.15-oracle. No risk, only a test change. Clean backport. Test starts up properly. SAP nightly testing passed.
17-12-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk17u-dev/pull/3120 Date: 2024-12-16 09:24:50 +0000
16-12-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk21u-dev/pull/1238 Date: 2024-12-16 09:24:36 +0000
16-12-2024

Changeset: aaaa86b5 Author: Renjith Kannath Pariyangad <rkannathpari@openjdk.org> Committer: Alexey Ivanov <aivanov@openjdk.org> Date: 2024-06-11 11:47:19 +0000 URL: https://git.openjdk.org/jdk/commit/aaaa86b57172d45d1126c50efc270c6e49aba7a5
11-06-2024