Skip to content
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

8304913: Use OperatingSystem, Architecture, and Version in jlink #13585

Closed
wants to merge 31 commits into from

Conversation

RogerRiggs
Copy link
Contributor

@RogerRiggs RogerRiggs commented Apr 21, 2023

Refactor the Platform class of jlink to use jdk.internal.util OperatingSystem and Architecture instead of os.name and os.arch.
They are direct replacements for the Platform enums except for UNKNOWN; its use is refactored to report errors via exceptions.

Neither os.name nor os.arch should be assumed to be changeable;
one test case is removed because it assumes os.name can be changed on the command line.


Progress

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

Issue

  • JDK-8304913: Use OperatingSystem, Architecture, and Version in jlink

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13585

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13585.diff

Webrev

Link to Webrev Comment

Merge amd64 and X64 to a single Architecture
…num.

Refactor the is64Bit method to be a static method for the current runtime.
Rename S390X to S390, representing just the s390 architecture
Removed ARM and IA64 enum values; they are unused; they can be added later if needed
All platforms and architectures that can be built support attach.
…values.

Unrecognized values from the build are mapped to enum value "OTHER".
Renamed PPC64LE to PPC64 to reflect only the architecture, not the endianness.
Added an `isLittleEndian` method to return the endianness (not currently used anywhere)
Refactor OperatingSystem initialization to use strings instead of integers.
against Unsafe respective values.
Relocated code mapping OS name and arch name from PlatformProps to
OperatingSystem and Architecture. Kept the mapping of names
in the template close to where the values are filled in by the build.
Consolidated switch cases in ArchTest.
Moved mapping of build TARGET_OS and TARGET_CPU to the build
to avoid multiple mappings in more than one place.
@bridgekeeper
Copy link

bridgekeeper bot commented Apr 21, 2023

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

@openjdk openjdk bot changed the title 8304913 8304913: Use OperatingSystem, Architecture, and Version in jlink Apr 21, 2023
@openjdk
Copy link

openjdk bot commented Apr 21, 2023

@RogerRiggs The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Apr 21, 2023
@openjdk-notifier openjdk-notifier bot changed the base branch from pr/13584 to master May 1, 2023 18:01
@openjdk-notifier
Copy link

The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout 8304913-os-arch-jlink
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

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

These latest changes look OK to me.

I have very limited knowledge of this area, so it would be good to wait for another review.

@openjdk
Copy link

openjdk bot commented May 5, 2023

@RogerRiggs 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:

8304913: Use OperatingSystem, Architecture, and Version in jlink

Reviewed-by: jpai, alanb, mchung

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 65 new commits pushed to the master branch:

  • a05560d: 8305990: Stripping debug info of ASM 9.5 fails
  • 040cb7b: 8307588: [JVMCI] HotSpotConstantPool#lookupBootstrapMethodInvocation broken by JDK-8301995
  • f92d095: 8307411: Test java/foreign/channels/TestAsyncSocketChannels.java failed: IllegalStateException: Already closed
  • 7a3bea1: 8307629: FunctionDescriptor::toMethodType should allow sequence layouts (mainline)
  • d2b3eef: 8307131: C2: assert(false) failed: malformed control flow
  • cd5d0ff: 8304031: Classfile API cannot encode Primitive Class as Condy
  • 07f55c5: 8305950: Have -XshowSettings option display tzdata version
  • d9052b9: 8307130: Open source few Swing JMenu tests
  • 5e1fe43: 8299229: [JVMCI] add support for UseZGC
  • 14df5c1: 8307165: java/awt/dnd/NoFormatsDropTest/NoFormatsDropTest.java timed out
  • ... and 55 more: https://git.openjdk.org/jdk/compare/0c6529d2d38a668f74936cca7803ca9de1a05d49...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 5, 2023
@openjdk openjdk bot added ready Pull request is ready to be integrated and removed ready Pull request is ready to be integrated labels May 5, 2023
OperatingSystem os = OperatingSystem.valueOf(osName.toUpperCase(Locale.ROOT));

archName = platformString.substring(index + 1);
// Unalias Jmod architecture "amd64" to "x86_64"
Copy link
Contributor

Choose a reason for hiding this comment

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

"Jmod architecture" is confusing here, it's the architecture component of the ModuleTarget attribute.

Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

Aside from one confusing comment, this change looks okay.

Copy link
Member

@mlchung mlchung left a comment

Choose a reason for hiding this comment

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

I suggest to remove Platform::is64Bit and simply call arch().is64bit(). Otherwise, looks fine.

return new Platform(os, arch);
}

/**
* @return true is it's a 64-bit platform
*/
public boolean is64Bit() {
return (arch() == Platform.Architecture.x64 ||
arch() == Platform.Architecture.AARCH64);
return Architecture.is64bit();
Copy link
Member

Choose a reason for hiding this comment

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

Platform::is64Bit tests if the target architecture is 64-bit but Architecture.is64bit() tests the runtime architecture.

*/
public boolean is64Bit() {
return (arch() == Platform.Architecture.x64 ||
arch() == Platform.Architecture.AARCH64);
return arch != Architecture.X86;
Copy link
Member

Choose a reason for hiding this comment

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

Have you considered having an instance Architecture::is64bit method in lieu of the current static method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly, if a need subsequently arises.
The only current use is in CDSPlugin and it is testing if the current/runtime platform is 64-bit so it can create the non-oop archive. The Architecture.is64bit() provides that. The current Platform.is64Bit() method is not needed.

*/
public boolean is64Bit() {
return (arch() == Platform.Architecture.x64 ||
arch() == Platform.Architecture.AARCH64);
return arch != Architecture.X86;
Copy link
Contributor

Choose a reason for hiding this comment

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

This change causes incorrect results to be returned on Linux ARM32.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My mistake; see above, Platform.is64Bit() is not needed by CDSPlugin.

On 64-bit runtimes, the non-compressed oop CDS archive is generated.
@RogerRiggs
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented May 15, 2023

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

  • 0f7b1c5: 8299340: CreateProcessW lpCommandLine must be mutable
  • 57e7a3f: 8307959: Remove explicit type casts from SerializeClosure::do_xxx() calls
  • 97b2ca3: 8307997: gtest:ZIndexDistributorTest fails on PPC64
  • ffab1ea: 8308086: GHA: x86_32 host configuration failing with unmet dependencies
  • ad348a8: 8303512: Race condition when computing is_loaded property of TypePtr::InterfaceSet
  • 911cc7c: 8305819: LogConfigurationTest intermittently fails on AArch64
  • 8d49ba9: 8308072: [BACKOUT] update for deprecated sprintf for src/utils
  • 0ee196b: 8307163: JLONG_FORMAT_SPECIFIER should be updated on Windows
  • 3709344: 8291550: RISC-V: jdk uses misaligned memory access when AvoidUnalignedAccess enabled
  • 646747f: 8307926: Support byte-sized atomic bitset operations
  • ... and 155 more: https://git.openjdk.org/jdk/compare/0c6529d2d38a668f74936cca7803ca9de1a05d49...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 15, 2023
@openjdk openjdk bot closed this May 15, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 15, 2023
@openjdk
Copy link

openjdk bot commented May 15, 2023

@RogerRiggs Pushed as commit 01892f9.

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

@RogerRiggs RogerRiggs deleted the 8304913-os-arch-jlink branch December 11, 2023 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
5 participants