On Thu, 30 Oct 2025 21:17:50 GMT, Phil Race <[email protected]> wrote:

>> Synchronize WPrinterJob calls which use the printDC to avoid crash in case 
>> of mis-use.
>> The printerDC is released when the job ends. 
>> It is zero-ed out in the handle in which it is stored
>> The calls which expect it to be valid now all check for zero and return if 
>> it is zero.
>> The calls are made synchronized as is the call to endDoc which zeroes it, so 
>> that they cannot have it zeroed out whilst using it.
>> 
>> The tests are the same as in the fix for JDK-8370141 which is also under 
>> review.
>> Which ever is 2nd to be pushed will have to merge in the changes from the 
>> first
>
> Phil Race has updated the pull request with a new target base due to a merge 
> or a rebase. The pull request now contains four commits:
> 
>  - 8370637
>  - 8370637
>  - Merge
>  - 8370637

Marked as reviewed by azvegint (Reviewer).

src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java line 956:

> 954:     }
> 955: 
> 956:     protected synchronized void beginPath() {

Perhaps this is a topic for a different PR, but the `protected` keyword is 
redundant here, as well as in many other places in the class, because the 
`WPrinterJob` is a final class.

src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp line 1589:

> 1587:     if ((HDC)dc != NULL) {
> 1588:         DeletePrintDC((HDC)dc);
> 1589:      }

Suggestion:

    if ((HDC)dc != NULL) {
        DeletePrintDC((HDC)dc);
    }


The closing brace is misaligned here and in all other cases.

src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp line 1871:

> 1869:     TRY;
> 1870: 
> 1871:     if ((HDC)printDC == NULL) {

There is no need to place this check inside the try-catch block.

src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp line 2249:

> 2247:     if ((HDC)printDC == NULL) {
> 2248:          return;
> 2249:      }

Suggestion:

  if ((HDC)printDC == NULL) {
    return;
  }


There are several cases of similar alignment issues.

-------------

PR Review: https://git.openjdk.org/jdk/pull/27984#pullrequestreview-3409406830
PR Review Comment: https://git.openjdk.org/jdk/pull/27984#discussion_r2485346330
PR Review Comment: https://git.openjdk.org/jdk/pull/27984#discussion_r2485315283
PR Review Comment: https://git.openjdk.org/jdk/pull/27984#discussion_r2485332854
PR Review Comment: https://git.openjdk.org/jdk/pull/27984#discussion_r2485329414

Reply via email to