Skip to content

8274893: Update java.desktop classes to use try-with-resources#686

Closed
TimPushkin wants to merge 3 commits intoopenjdk:masterfrom
TimPushkin:8274893-jdk8
Closed

8274893: Update java.desktop classes to use try-with-resources#686
TimPushkin wants to merge 3 commits intoopenjdk:masterfrom
TimPushkin:8274893-jdk8

Conversation

@TimPushkin
Copy link
Copy Markdown
Contributor

@TimPushkin TimPushkin commented Sep 1, 2025

Backport of JDK-8274893 for parity with Oracle's JDK 8u461.

Resolved conflicts:

  • jdk/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
    • Missing JDK-8271456: "ISO-8859-1" string is used instead of ISO_8859_1 enum constant
    • Missing JDK-8041679: StringBuffer is used instead of StringBuilder
  • jdk/src/share/classes/javax/swing/text/html/HTMLEditorKit.java
    • Missing JDK-8271456: "ISO-8859-1" string is used instead of ISO_8859_1 enum constant
  • jdk/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java
    • Missing JDK-8143909: no Objects.requireNonNull(...) in this version
  • jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java
    • Missing JDK-8054834: imports from sun.font package are still needed in this file
  • jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
    • Missing JDK-8080835: use IOUtils.readAllBytes(InputStream is) instead of the missing InputStream.readAllBytes()
  • Missing JDK-7196163: try-with-resources cannot be used with pre-existing variables — fell back to try-finally in such cases

Testing: GitHub CI, jdk_imageio test group locally (headless linux/arm64)


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • JDK-8274893 needs maintainer approval
  • Commit message must refer to an issue

Issue

  • JDK-8274893: Update java.desktop classes to use try-with-resources (Enhancement - P5 - Approved)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk8u-dev.git pull/686/head:pull/686
$ git checkout pull/686

Update a local copy of the PR:
$ git checkout pull/686
$ git pull https://git.openjdk.org/jdk8u-dev.git pull/686/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 686

View PR using the GUI difftool:
$ git pr show -t 686

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk8u-dev/pull/686.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Sep 1, 2025

👋 Welcome back tpushkin! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Sep 1, 2025

@TimPushkin This change now passes all automated pre-integration checks.

After integration, the commit message for the final commit will be:

8274893: Update java.desktop classes to use try-with-resources

Reviewed-by: andrew

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 1 new commit pushed to the master branch:

  • 3728209: 8377344: [8u] Compilation failure on Windows for Linux-specific platform metric tests

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@gnu-andrew) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk Bot changed the title Backport 70c6df6be431fe11c5441986ed04040f9ec3b750 8274893: Update java.desktop classes to use try-with-resources Sep 1, 2025
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Sep 1, 2025

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk Bot added backport Port of a pull request already in a different code base rfr Pull request is ready for review labels Sep 1, 2025
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented Sep 1, 2025

Webrevs

return null;
try
{
try {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be try-with-resources

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was in the original change but in this JDK try-with-resources on an existing variable is not possible (no JDK-7196163), so I fell back to try-finally. This is not the only place where I've done this, see 832c3c3.

Alternatives are to either create a copy variable for try-with-resources (which also must be used inside it to prevent a compiler warning) or move all interactions with the variable inside try-with-resources — both diverge code from the original change and the pre-existing code so I decided against them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we revert formatting changes here, then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure what would be the best here: keeping the existing formatting to changing it to be closer to the backported change — and went with the latter.

Since I don't really have a strong preference, reverted to the old one now as you suggest.

@TimPushkin
Copy link
Copy Markdown
Contributor Author

I believe test failures are not related

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Sep 30, 2025

@TimPushkin This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@TimPushkin
Copy link
Copy Markdown
Contributor Author

/touch

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Sep 30, 2025

@TimPushkin The pull request is being re-evaluated and the inactivity timeout has been reset.

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Oct 28, 2025

@TimPushkin This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@TimPushkin
Copy link
Copy Markdown
Contributor Author

/touch

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Oct 28, 2025

@TimPushkin The pull request is being re-evaluated and the inactivity timeout has been reset.

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Nov 26, 2025

@TimPushkin This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@TimPushkin
Copy link
Copy Markdown
Contributor Author

/touch

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Nov 26, 2025

@TimPushkin The pull request is being re-evaluated and the inactivity timeout has been reset.

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Dec 24, 2025

@TimPushkin This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@TimPushkin
Copy link
Copy Markdown
Contributor Author

/touch

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Dec 24, 2025

@TimPushkin The pull request is being re-evaluated and the inactivity timeout has been reset.

Backport-of: 70c6df6be431fe11c5441986ed04040f9ec3b750
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Dec 26, 2025

@TimPushkin Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@TimPushkin
Copy link
Copy Markdown
Contributor Author

Rebased on top of the current master

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Jan 23, 2026

@TimPushkin This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@TimPushkin
Copy link
Copy Markdown
Contributor Author

/keepalive

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Jan 26, 2026

@TimPushkin The pull request is being re-evaluated and the inactivity timeout has been reset.

Copy link
Copy Markdown
Member

@gnu-andrew gnu-andrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good to me. Just a few comments:

  • For the case in com.sun.media.sound.JARSoundbankReader.java, only a null check is outside the try block. Could that not be moved inside and the block converted to try-with-resources?
  • For the is case in com.sun.media.sound.SoftSynthesizer.java, could we not move the is declaration into a try-with-resources block? The only use outside thetry is a null check.

The other cases I think we are stuck with try-finally blocks.

@TimPushkin
Copy link
Copy Markdown
Contributor Author

The test failures don't seem related:

  • security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java#digicerttlsrsarootg5 is the one failed in almost all of the cases ("Failed to validate https://digicert-tls-rsa4096-root-g5-revoked.chain-demos.digicert.com/") — there was already JDK-8333937 some time ago with a similar error (not in the description but in the comments) and it was resolved externally
  • compiler/5091921/Test7005594.java failed twice ("Test7005594.sh: 40: Bad substitution") — already reported as JDK-8376951
  • gc/logging/TestGCId.java failed once (timeout)

@TimPushkin TimPushkin requested a review from gnu-andrew February 9, 2026 12:13
@gnu-andrew
Copy link
Copy Markdown
Member

The test failures don't seem related:

I agree.

* `security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java#digicerttlsrsarootg5` is the one failed in almost all of the cases ("Failed to validate https://digicert-tls-rsa4096-root-g5-revoked.chain-demos.digicert.com/") —  there was already [JDK-8333937](https://bugs.openjdk.org/browse/JDK-8333937) some time ago with a similar error (not in the description but in the comments) and it was resolved externally

I've seen this one on my own recent PRs (e.g. openjdk/shenandoah-jdk8u#122) and it seems to have turned up this weekend.

* `compiler/5091921/Test7005594.java` failed twice ("Test7005594.sh: 40: Bad substitution") — already reported as [JDK-8376951](https://bugs.openjdk.org/browse/JDK-8376951)

This should be resolved once #755 goes in.

* `gc/logging/TestGCId.java` failed once (timeout)

I think this is a sporadic failure and can't see a HotSpot test failure being related to these JDK code changes.

Copy link
Copy Markdown
Member

@gnu-andrew gnu-andrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the additional changes. You managed to cover more cases than I expected and it looks good.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Feb 11, 2026

⚠️ @TimPushkin This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

@TimPushkin
Copy link
Copy Markdown
Contributor Author

/approval request Backporting for parity with Oracle and to make a dependent in-progress backport cleaner.
Low risk. The change is a cleanup limited to multimedia classes (jdk.desktop in newer JDKs), it should not change the behavior.
Testing: GitHub CI, jdk_imageio test group locally (headless linux/arm64).

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Feb 11, 2026

@TimPushkin
8274893: The approval request has been created successfully.

@openjdk openjdk Bot added the approval Requires approval; will be removed when approval is received label Feb 11, 2026
@gnu-andrew
Copy link
Copy Markdown
Member

/approve yes

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Feb 11, 2026

@gnu-andrew
8274893: The approval request has been approved.

@openjdk openjdk Bot added ready Pull request is ready to be integrated and removed approval Requires approval; will be removed when approval is received labels Feb 11, 2026
@TimPushkin
Copy link
Copy Markdown
Contributor Author

/integrate

@openjdk openjdk Bot added the sponsor Pull request is ready to be sponsored label Feb 11, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Feb 11, 2026

@TimPushkin
Your change (at version bdb9a1e) is now ready to be sponsored by a Committer.

@gnu-andrew
Copy link
Copy Markdown
Member

/sponsor

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Feb 18, 2026

Going to push as commit d043a24.
Since your change was applied there have been 2 commits pushed to the master branch:

  • 97fdbd0: 8170464: Remove shell script from compiler/c2/cr7005594/Test7005594.java
  • 3728209: 8377344: [8u] Compilation failure on Windows for Linux-specific platform metric tests

Your commit was automatically rebased without conflicts.

@openjdk openjdk Bot added the integrated Pull request has been integrated label Feb 18, 2026
@openjdk openjdk Bot closed this Feb 18, 2026
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Feb 18, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Feb 18, 2026

@gnu-andrew @TimPushkin Pushed as commit d043a24.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Port of a pull request already in a different code base integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants