Skip to content

Conversation

@david-beaumont
Copy link
Contributor

@david-beaumont david-beaumont commented Dec 19, 2025

Hopefully a fix for preview mode with exploded images in classLoader.cpp.

I did a little renaming since now it's clear that "preview mode" isn't a thing that's limited only to a jimage being present.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 Committer)

Issue

  • JDK-8373987: [lworld] exploded-image/test broken since disable patching (JDK-8373806) (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1845/head:pull/1845
$ git checkout pull/1845

Update a local copy of the PR:
$ git checkout pull/1845
$ git pull https://git.openjdk.org/valhalla.git pull/1845/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1845

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1845.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 19, 2025

👋 Welcome back david-beaumont! A progress list of the required criteria for merging this PR into lworld 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 Dec 19, 2025

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

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

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

8373987: [lworld] exploded-image/test broken since disable patching (JDK-8373806)

Reviewed-by: coleenp, rriggs

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 111 new commits pushed to the lworld 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 (@coleenp, @RogerRiggs) 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).

@david-beaumont david-beaumont changed the title Seems to work ... 8373987: [lworld] exploded-image/test broken since disable patching (JDK-8373806) Dec 19, 2025
JIMAGE_MODE_UNINITIALIZED = 0,
JIMAGE_MODE_DEFAULT = 1,
JIMAGE_MODE_ENABLE_PREVIEW = 2
// PreviewMode status to control preview behaviour. JImage_file is unusable
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally automated search & replace.

return file_name;
}

// caller needs ResourceMark
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the code above. Both these should probably use stringStream and format specifiers according to several people. I don't want to do that in this PR though.

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as it doesn't have a buffer overrun, it's fine to fix later. It seems okay.

assert(_exploded_entries != nullptr, "No exploded build entries present");
assert(!CDSConfig::is_dumping_archive(), "CDS dumping doesn't support exploded build");
stream = search_module_entries(THREAD, _exploded_entries, pkg_entry, file_name);
const char* preview_file_name = is_preview_enabled() ? create_preview_file_name(file_name) : nullptr;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making this out here seems best, but I could also pass the flag in and make it in search_module_entries(), but that's called from two places, so the less complexity in there the better.

jimage_init(enable_preview);
}
void ClassLoader::set_preview_mode(bool enable_preview) {
assert(Preview_mode == PREVIEW_MODE_UNINITIALIZED, "set_preview_mode must not be called twice");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't check for jimage now since it won't be there when using exploded image.

static char* get_canonical_path(const char* orig, Thread* thread);
static const char* file_name_for_class_name(const char* class_name,
int class_name_len);
// REVIEWER-NOTE: Where best to put this - it should be private!
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this should be here, but several other "private looking" functions are in the public section so I'm not sure. Advice requested...

Copy link
Contributor

Choose a reason for hiding this comment

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

Move it up to the private section.

@david-beaumont david-beaumont marked this pull request as ready for review December 19, 2025 15:53
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 19, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 19, 2025

Webrevs

Comment on lines +1072 to +1077
if (nullptr != preview_file_name) {
stream = e->open_stream(current, preview_file_name);
}
if (nullptr == stream) {
stream = e->open_stream(current, file_name);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not pass in the preview flag to search_module_entries (or use the global) and create and preview file name here?
Its better encapsulated, with a smaller scope knowing about META-INF.

Copy link
Contributor Author

@david-beaumont david-beaumont Dec 19, 2025

Choose a reason for hiding this comment

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

As I said in the comment, I could. I didn't because search_module_entries is called in two places, and the call for exploded image is the edge case. So passing just a "try this first" path without the logic of accessing the preview mode flag and building the preview path felt simpler for the normal case.
I can't use the global flag inside the method of course, because that triggers it in the non-exploded image case.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

This seems all right.

static char* get_canonical_path(const char* orig, Thread* thread);
static const char* file_name_for_class_name(const char* class_name,
int class_name_len);
// REVIEWER-NOTE: Where best to put this - it should be private!
Copy link
Contributor

Choose a reason for hiding this comment

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

Move it up to the private section.

return file_name;
}

// caller needs ResourceMark
Copy link
Contributor

Choose a reason for hiding this comment

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

As long as it doesn't have a buffer overrun, it's fine to fix later. It seems okay.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 19, 2025
Copy link
Collaborator

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

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

Looks fine.

@david-beaumont
Copy link
Contributor Author

A better version of the fix is: #1854

@david-beaumont david-beaumont deleted the jdk_8373987 branch December 22, 2025 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants