8357179: Deprecate VFORK launch mechanism from Process implementation (linux)

Reviewed-by: rriggs
This commit is contained in:
Thomas Stuefe 2025-05-21 04:39:35 +00:00
parent cedd1a5343
commit 74fc4e4ee7

View File

@ -100,16 +100,26 @@ final class ProcessImpl extends Process {
// Should be value of a LaunchMechanism enum
LaunchMechanism lm = LaunchMechanism.valueOf(s.toUpperCase(Locale.ROOT));
switch (OperatingSystem.current()) {
case LINUX:
return lm; // All options are valid for Linux
case LINUX: {
// All options are valid for Linux, but VFORK is deprecated and results
// in a warning
if (lm == LaunchMechanism.VFORK) {
System.err.println("VFORK MODE DEPRECATED");
System.err.println("""
The VFORK launch mechanism has been deprecated for being dangerous.
It will be removed in a future java version. Either remove the
jdk.lang.Process.launchMechanism property (preferred) or use FORK mode
instead (-Djdk.lang.Process.launchMechanism=FORK).
""");
}
return lm;
}
case AIX:
case MACOS:
if (lm != LaunchMechanism.VFORK) {
return lm; // All but VFORK are valid
}
break;
case WINDOWS:
// fall through to throw to Error
}
} catch (IllegalArgumentException e) {
}