Skip to content

Commit c413cdb

Browse files
committed
[GR-70225] Apply java_util_prefs substitution only if java.prefs module is present.
PullRequest: graal/22269
2 parents f37acef + 7c900d1 commit c413cdb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSubstitutions.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import static com.oracle.svm.core.posix.headers.darwin.DarwinTime.NoTransitions.mach_timebase_info;
2929

3030
import java.util.Objects;
31+
import java.util.function.BooleanSupplier;
3132

3233
import org.graalvm.nativeimage.ImageSingletons;
3334
import org.graalvm.nativeimage.Platform;
@@ -122,7 +123,7 @@ long nanoTime() {
122123
* Native functions don't exist on Darwin because this whole class is used, and should exist, only
123124
* on Linux. See <code>java.util.prefs.Preferences#factory</code>.
124125
*/
125-
@TargetClass(className = "java.util.prefs.FileSystemPreferences")
126+
@TargetClass(className = "java.util.prefs.FileSystemPreferences", onlyWith = IsJavaUtilPrefsPresent.class)
126127
final class Target_java_util_prefs_FileSystemPreferences {
127128
@Delete
128129
private static native int[] lockFile0(String fileName, int permission, boolean shared);
@@ -134,6 +135,14 @@ final class Target_java_util_prefs_FileSystemPreferences {
134135
private static native int chmod(String fileName, int permission);
135136
}
136137

138+
final class IsJavaUtilPrefsPresent implements BooleanSupplier {
139+
@Override
140+
public boolean getAsBoolean() {
141+
var prefsMod = ModuleLayer.boot().findModule("java.prefs");
142+
return prefsMod.isPresent();
143+
}
144+
}
145+
137146
/**
138147
* Not used in native image and has linker errors with XCode 13. Can be removed in the future when
139148
* XCode 14 becomes omnipresent.

0 commit comments

Comments
 (0)