From d659002680ef1af4d5648d8e130b71c9295b021c Mon Sep 17 00:00:00 2001 From: dae won Date: Mon, 16 Dec 2024 17:52:16 +0900 Subject: [PATCH] refactor: Resolve System.getProperty(java.home) null issue in native image --- .../org/springframework/boot/system/ApplicationTemp.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationTemp.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationTemp.java index 2ab9f745f574..c3e8d625f997 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationTemp.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationTemp.java @@ -31,6 +31,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import org.springframework.core.NativeDetector; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -145,7 +146,10 @@ private byte[] generateHash(Class sourceClass) { update(digest, home.getSource()); update(digest, home.getDir()); update(digest, System.getProperty("user.dir")); - update(digest, System.getProperty("java.home")); + if (!NativeDetector.inNativeImage()) { + String javaHome = System.getProperty("java.home"); + update(digest, javaHome); + } update(digest, System.getProperty("java.class.path")); update(digest, System.getProperty("sun.java.command")); update(digest, System.getProperty("sun.boot.class.path"));