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

add detection for IBM Semeru Java runtime and fix x86 detection on 64 bit Windows #2428

Merged
merged 4 commits into from
Jun 7, 2024

Conversation

Fourmisain
Copy link
Contributor

IBM Semeru uses OpenJ9, which is known to be quite memory efficient, making it potentially interesting for large modpacks.

The detection code is a straight forward copy of the Eclipse Adoptium detection, substituting
Eclipse Adoptium -> Semeru, ADOPTIUM -> SEMERU, hotspot -> openj9

Tested working with 8.0.402.0 x64 JDK and 17.0.10.0 x64 JRE. (I assume x86 should just work.)

P.S.
MSYS2's build instructions are missing qt6-networkauth:p in the pacboy step if someone reading wants to fix it.

@Trial97
Copy link
Member

Trial97 commented May 20, 2024

Is this only for windows?

@Fourmisain
Copy link
Contributor Author

Fourmisain commented May 20, 2024

Is this only for windows?

Yes. I have no idea how/if detection on Linux is done.

I also just tested x86 and it looks like all the detection code is sort of broken for it.
If you install a 32 bit Java on a 64 bit OS, it generally installs into WOW6432Node, which this code does not test for at all (I thought the KEY_WOW64_32KEY would magically do that).

For comparison, registry paths for x86 and x64 on 64 bit Windows are

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Eclipse Adoptium\JRE\17.0.11.9\hotspot\MSI
HKEY_LOCAL_MACHINE\SOFTWARE\Eclipse Adoptium\JDK\17.0.11.9\hotspot\MSI

I guess it's not a huge deal since you generally won't use 32 bit Java on a 64 bit machine since the only advantage is lower memory consumption, but it's also limited to 4GB, so it's pretty much pointless.

@Ryex
Copy link
Contributor

Ryex commented May 20, 2024

Hey, just looked into things

looks like on macos ibm semeru would be installed to
/Library/Java/JavaVirtualMachines/ibm-semeru-open-<version>.<jdk|jre>/
with the official installer and similar with homebrew.
/Library/Java/JavaVirtualMachines/ is already checked so no change is needed there.

with linux the official RPM uses

    Certified edition: /opt/ibm
    Open edition: /usr/lib/jvm/

other distros are likely going to use similar
/usr/lib/jvm/ is already checked so only /opt/ibm would need to be added

@Fourmisain
Copy link
Contributor Author

Fourmisain commented May 20, 2024

I just looked into the x86 thing a bit.
I think the code is trying to do the right thing, passing in the KEY_WOW64_32KEY flag into RegOpenKeyExW, which presumably would check the "32 bit registry", which lies inside Wow6432Node... so I'm not sure why it doesn't seem to work.

The docs for RegOpenKeyExW don't help, they don't list any of the used flags...?

Gonna check it out tomorrow, the Linux/macOS detection as well if I can find the code - though I won't be able to test it.

@Fourmisain
Copy link
Contributor Author

Oh wait, maybe that's the issue?

if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, newKeyName.toStdWString().c_str(), 0, KEY_READ | KEY_WOW64_64KEY, &newKey) ==

It's always using KEY_WOW64_64KEY here.

Anyway. Tomorrow.

@Fourmisain
Copy link
Contributor Author

I had to quickly test it. It was indeed that.

@Fourmisain
Copy link
Contributor Author

looks like on macos ibm semeru would be installed to
/Library/Java/JavaVirtualMachines/ibm-semeru-open-.<jdk|jre>/
with the official installer and similar with homebrew.
/Library/Java/JavaVirtualMachines/ is already checked so no change is needed there.

Just read the code as well, I agree that it should already work.

with linux the official RPM uses

Certified edition: /opt/ibm
Open edition: /usr/lib/jvm/

other distros are likely going to use similar
/usr/lib/jvm/ is already checked so only /opt/ibm would need to be added

Added /opt/ibm.

That should be it. Thanks for the help!

@Fourmisain Fourmisain changed the title add detection for IBM Semeru Java runtime add detection for IBM Semeru Java runtime and fix x86 detection on 64 bit Windows May 21, 2024
@Trial97
Copy link
Member

Trial97 commented May 21, 2024

One more thing you need to do is to format your code(to please the pre-commit check).
Here are the changes that you need to make: https://github.com/PrismLauncher/PrismLauncher/pull/2428/checks?check_run_id=25216938174
If the changes are not obvious you can just run clang-format -i launcher/java/JavaUtils.cpp and it should format it.

@Fourmisain
Copy link
Contributor Author

clang-format -i launcher/java/JavaUtils.cpp didn't quite work, it put
"LD_LIBRARY_PATH",
"LD_PRELOAD"
and
"QT_PLUGIN_PATH",
"QT_FONTPATH"
in a single line, which the pre-commit check didn't like.

Force-pushed the correct formatting.

@TheKodeToad TheKodeToad added this to the 8.4 milestone Jun 7, 2024
@TheKodeToad TheKodeToad added the backport release-8.x Backport PR automatically label Jun 7, 2024
@TheKodeToad TheKodeToad merged commit 3ef5cd2 into PrismLauncher:develop Jun 7, 2024
32 checks passed
Copy link
Contributor

github-actions bot commented Jun 7, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release-8.x Backport PR automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants