Skip to content

Conversation

TimPushkin
Copy link

@TimPushkin TimPushkin commented Sep 1, 2025

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

The first commit is a cherry-pick of the backport to JDK 11 with conflicts unresolved, the second resolves the conflicts, the rest resolve issues uncaught by git.

Resolved:

  • 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)

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

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

openjdk bot commented Sep 1, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

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

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

mlbridge bot commented Sep 1, 2025

Webrevs

@@ -91,8 +88,7 @@ public Soundbank getSoundbank(URL url)
"META-INF/services/javax.sound.midi.Soundbank");
if (stream == null)
return null;
try
{
try {
Copy link
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
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
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
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
Author

I believe test failures are not related

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 rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants