-
Notifications
You must be signed in to change notification settings - Fork 124
8368333: [lworld] Add preview mode to ImageReader and JRT file-system #1619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: pr/1618
Are you sure you want to change the base?
Conversation
This is a new version of #1613, re-created so there's now a pr/xxx branch for use by dependent PRs. |
👋 Welcome back david-beaumont! A progress list of the required criteria for merging this PR into |
@david-beaumont This change is no longer ready for integration - check the PR body for details. |
Webrevs
|
* <p>Known jimage file code which needs updating on version change: | ||
* <ul> | ||
* <li>src/java.base/share/native/libjimage/imageFile.hpp | ||
* </ul> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any java source files that have to be updated on a version change?
/** | ||
* Set on all locations in the {@code /modules/xxx/META-INF/preview/...} | ||
* namespace. | ||
* | ||
* <p>This flag is mutually exclusive with {@link #FLAGS_HAS_PREVIEW_VERSION}. | ||
*/ | ||
public static final int FLAGS_IS_PREVIEW_VERSION = 0x2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be redundant with HAS_PREVIEW_VERSION when seen in a preview location.
/** | ||
* Indicates that a location only exists due to preview resources. | ||
* | ||
* <p>This can apply to both resources and directories in the | ||
* {@code /modules/xxx/...} namespace, as well as {@code /packages/xxx} | ||
* directories. | ||
* | ||
* <p>For {@code /packages/xxx} directories it indicates that, for every | ||
* module in which the package exists, it is preview only. | ||
* | ||
* <p>This flag is mutually exclusive with {@link #FLAGS_HAS_PREVIEW_VERSION} | ||
* and need not imply that {@link #FLAGS_IS_PREVIEW_VERSION} is set (i.e. | ||
* for {@code /packages/xxx} directories). | ||
*/ | ||
public static final int FLAGS_IS_PREVIEW_ONLY = 0x4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preview-only case is expected to be the empty set. There seems to be a lot of code dedicated to it.
* Helper function to calculate preview flags (ATTRIBUTE_PREVIEW_FLAGS). | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A summary of what gets what flags might be easier to read than the code.
Or list the flags and refer to their descriptions (that would describe the paths where the flags would be found)
* Indicates that a non-preview location is associated with preview | ||
* resources. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment would read better saying that preview resources exist related to this location.
More like FLAGS_HAS_PREVIEW_VERSION.
import static jdk.internal.jimage.ImageLocation.FLAGS_HAS_PREVIEW_VERSION; | ||
import static jdk.internal.jimage.ImageLocation.FLAGS_IS_PREVIEW_ONLY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import utility methods not flags.
return ensureCachedIfNonNull( | ||
loc != null && loc.getType() == RESOURCE ? newResource(name, loc) : null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems odd to test loc and type to produce a null and them pass it to a method that will do nothing.
The non-productive test can be done and return immediately.
if (envValue instanceof Boolean && (Boolean) envValue) { | ||
return PreviewMode.ENABLED; | ||
} else if (envValue instanceof String && Boolean.parseBoolean((String) envValue)) { | ||
return PreviewMode.ENABLED; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of ambiguous type for the environment variable should not be supported.
Pick a type and stick to it.
Whereever the jrt: file system is specified will need a description for enablePreview to be added to the spec.
// TODO: Maybe throw if enablePreview attempted for exploded image? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exploded image is useful for debugging, it could support preview mode using the same META-INF directory structure.
} | ||
|
||
// Encodes strings sequentially starting from index 100. | ||
private static Function<String, Integer> testEncoder() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name testEncoder
gives the impression of being a test, but it is just a utility function used by a test.
Java changes for supporting preview mode when preview mode resources (with new location flags) are available.
At the moment, this code will operate on non-preview jimage files (1.0) and act as if no preview resources are available by virtue of the default value for missing attributes and package flags being zero (which matches jimage 1.0).
This should be reviewed on top of #1618
Progress
Integration blocker
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1619/head:pull/1619
$ git checkout pull/1619
Update a local copy of the PR:
$ git checkout pull/1619
$ git pull https://git.openjdk.org/valhalla.git pull/1619/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1619
View PR using the GUI difftool:
$ git pr show -t 1619
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1619.diff
Using Webrev
Link to Webrev Comment