Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Review usages of System.getProperty("java.home") #43050

Open
mhalbritter opened this issue Nov 6, 2024 · 2 comments
Open

Review usages of System.getProperty("java.home") #43050

mhalbritter opened this issue Nov 6, 2024 · 2 comments
Assignees
Labels
type: task A general task
Milestone

Comments

@mhalbritter
Copy link
Contributor

mhalbritter commented Nov 6, 2024

When running in a native image, System.getProperty("java.home") will return null (as there is no Java involved).

The native image team wants to add a warning if this code is called as this can lead to subtle bugs. We should review our System.getProperty("java.home") usages and either remove them if not needed or guard for null / do not execute them when running in a native image.

@mhalbritter mhalbritter added the type: task A general task label Nov 6, 2024
@mhalbritter mhalbritter added this to the 3.x milestone Nov 6, 2024
@mhalbritter
Copy link
Contributor Author

mhalbritter commented Nov 6, 2024

org.springframework.boot.loader.tools.JavaExecutable, which uses java.home, is used by the Maven plugin and by the CLI, both no candidates for native image.

@mhalbritter
Copy link
Contributor Author

mhalbritter commented Nov 6, 2024

org.springframework.boot.system.ApplicationTemp#generateHash calculates a SHA-1 hash over different parts of data, one of which is java.home. The code still works if java.home is null.

This class is used by our webservers for the session store directory.

If we want to get rid of the planned native image warning, we could add this:

if (!NativeDetector.inNativeImage()) {
  update(digest, System.getProperty("java.home"));
}

@mhalbritter mhalbritter self-assigned this Nov 6, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: task A general task
Projects
None yet
Development

No branches or pull requests

1 participant