JDK-8333026 : java/awt/print/PrinterJob/PrintNullString.java failed: FAILURE: No IAE for empty iterator, int
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7,8,11,17,21,22,23,24
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • Submitted: 2024-05-28
  • Updated: 2025-05-26
  • Resolved: 2025-05-26
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.
Other
tbdResolved
Related Reports
Relates :  
Relates :  
Relates :  
Description
The java/awt/print/PrinterJob/PrintNullString.java test fails, the window displays:

FAILURE: No IAE for empty iterator, int
FAILURE: No IAE for empty iterator, float

When printed, there are no failures displayed.

---

OS:
Ubuntu Linux

Environments:
Operating System: Ubuntu 24.04 LTS
Language: English
Processor: Intel® Xeon® Silver 4210 × 8
OS type: 64-bit
Memory: 8 GB

Failed on Release/Build: JDK_23_b22
Is it a Regression in JDK 23 release: N/A
[If Regression] Regression introduced in JDK 23 release/build: N/A
Test result on the last GAed release for this train: N/A
Is it a platform-specific issue: No. This issue happens on Linux. Not tested on macOS and Windows yet.

Steps to reproduce:

        Step 1. Open terminal and run command:

#!/bin/sh -x
export JAVA_HOME=/home/ubuntu/Desktop/Reg/jdk-23
export JT_HOME=/home/ubuntu/Desktop/Reg/jtreg
export PATH=$PATH:$JAVA_HOME/bin:$JT_HOME/bin

jtreg \
-ignore:quiet \
-ea \
-esa \
-m \
-gui \
-e:SWINGSET2_JAR=file:///home/ubuntu/Desktop/Reg/jdk-23-ea+22_linux-x64_bin-tests/jdk/demos/jfc/SwingSet2/SwingSet2.jar \
-nativepath:/home/ubuntu/Desktop/Reg/jdk-23-ea+22_linux-x64_bin-tests/jdk/jtreg/native \
-exclude:/home/ubuntu/Desktop/Reg/open/test/jdk/ProblemList.txt \
-testjdk:/home/ubuntu/Desktop/Reg/jdk-23 \
-dir:/home/ubuntu/Desktop/Reg/open/test/jdk \
-reportDir:results/JTreport \
-workDir:results/JTwork \
-timeoutHandlerDir:/home/ubuntu/Desktop/Reg/jdk-23-ea+22_linux-x64_bin-tests/failure_handler/jtregFailureHandler.jar \
-observerDir:/home/ubuntu/Desktop/Reg/jdk-23-ea+22_linux-x64_bin-tests/failure_handler/jtregFailureHandler.jar \
-timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
-observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
-timeoutHandlerTimeout:0 \
/home/ubuntu/Desktop/Reg/open/test/jdk/:jdk_desktop

           Step 2. Run test case: java/awt/print/PrinterJob/PrintNullString.java
           Step 3. Click on print button
           Step 4. Observe the physical copy

Expected behavior:
The physical copy is the same as the test window on the screen

Actual behavior:
The physical copy is NOT the same as the test window on the screen

Any non-default VM flags
/home/ubuntu/Desktop/Reg/jdk-23/bin/java \\
        -Dtest.vm.opts='-ea -esa' \\
        -Dtest.tool.vm.opts='-J-ea -J-esa' \\
        -Dtest.compiler.opts= \\
        -Dtest.java.opts= \\
        -Dtest.jdk=/home/ubuntu/Desktop/Reg/jdk-23 \\
        -Dcompile.jdk=/home/ubuntu/Desktop/Reg/jdk-23 \\
        -Dtest.timeout.factor=1.0 \\
        -Dtest.nativepath=/home/ubuntu/Desktop/Reg/jdk-23-ea+22_linux-x64_bin-tests/jdk/jtreg/native \\
        -Dtest.root=/home/ubuntu/Desktop/Reg/open/test/jdk \\
        -Dtest.name=java/awt/print/PrinterJob/PrintNullString.java \\
        -Dtest.file=/home/ubuntu/Desktop/Reg/open/test/jdk/java/awt/print/PrinterJob/PrintNullString.java \\
        -Dtest.src=/home/ubuntu/Desktop/Reg/open/test/jdk/java/awt/print/PrinterJob \\
        -Dtest.src.path=/home/ubuntu/Desktop/Reg/open/test/jdk/java/awt/print/PrinterJob:/home/ubuntu/Desktop/Reg/open/test/jdk/java/awt/regtesthelpers \\
        -Dtest.classes=/home/ubuntu/Desktop/Reg/results/JTwork/classes/java/awt/print/PrinterJob/PrintNullString.d \\
        -Dtest.class.path=/home/ubuntu/Desktop/Reg/results/JTwork/classes/java/awt/print/PrinterJob/PrintNullString.d:/home/ubuntu/Desktop/Reg/results/JTwork/classes/java/awt/regtesthelpers \\
        -Dtest.modules=java.desktop \\
        --add-modules java.desktop \\
        -ea \\
        -esa \\
        -Djava.library.path=/home/ubuntu/Desktop/Reg/jdk-23-ea+22_linux-x64_bin-tests/jdk/jtreg/native \\
        com.sun.javatest.regtest.agent.MainWrapper /home/ubuntu/Desktop/Reg/results/JTwork/java/awt/print/PrinterJob/PrintNullString.d/main.0.jta
Comments
It's an interesting case… I still think it's a valid bug… Graphics for rendering UI should behave consistently with the print Graphics. We need to discuss this issue further.
26-05-2025

UI removed part of JDK-8334016 fix and this issue no longer applicable. So closing this as not an issue
26-05-2025

Is it not a platform-specific, happening for all OS.
03-06-2024

The specification for Graphics2D.drawString https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/Graphics2D.html#drawString(java.text.AttributedCharacterIterator,float,float) https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/Graphics2D.html#drawString(java.text.AttributedCharacterIterator,int,int) says nothing about throwing IllegalArgumentException if the iterator is an empty iterator. At the same time, the regression test, PrintNullString.java, exists and ensures this behaviour. SunGraphics2D was modified by JDK-6699843 in Java 7 where it stopped throwing IllegalArgumentException if empty string or empty iterator is passed. If it is the desired behaviour, the test and other implementations of Graphics2D should be updated accordingly.
31-05-2024

I ran the test on Windows with the most recent promoted build (build 23-ea+25-2094), and the test fails. According to the instructions: “The messages should contain only 'OK' and 'expected' messages. Press Pass if it's the case; otherwise press Fail.” the test must fail if you see anything but 'OK' and 'expected' and you see 'FAILURE' twice. So, you don't even need to print — the test fails because no IllegalArgumentException is thrown by Graphics2D.drawString(AttributedCharacterIterator, …). It is a product bug.
31-05-2024

> Is it a platform-specific issue: No. This issue happens on Linux. If the issue happens on Linux only, then it is platform-specific. Do I get anything wrong? > Not tested on macOS and Windows yet. This means it's not known at this moment whether it's platform-specific or not, since the test was run on Linux only.
31-05-2024

Should the implementation of PeekGraphics align with SunGraphics2D? The following two points aren't clear to me: Does the test pass in its unmodified form, before JDK-8324808? Does the updated test fail? According to Affects Version, the test fails for both cases since the test fails in 23 where it was updated by JDK-8324808 and in 22 and 21, however, JDK-8324808 isn't backported to any previous release. If it's the case, the failure is applicable to all releases: 8, 11, 17, 21, 22, 23… unless there's a change in underlying implementation of Graphics. Before JDK-8324808, the tester had no way of failing the test. The test was open-sourced by JDK-8038723 in 2014.
31-05-2024

Seems like console drawString takes SunGraphics2D#drawString path which just return for empty iterator while printing drawString takes PeekGraphics#drawString path calling TextLayout which throws IAE
29-05-2024

Opensourced in JDK-8324808.. Was it not failing then?
29-05-2024

[~landrews] is it a regression in 23? Could you look at it Today please?
28-05-2024