Skip to content

Commit 74fc4e4

Browse files
committed
8357179: Deprecate VFORK launch mechanism from Process implementation (linux)
Reviewed-by: rriggs
1 parent cedd1a5 commit 74fc4e4

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/java.base/unix/classes/java/lang/ProcessImpl.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,26 @@ private static LaunchMechanism launchMechanism() {
100100
// Should be value of a LaunchMechanism enum
101101
LaunchMechanism lm = LaunchMechanism.valueOf(s.toUpperCase(Locale.ROOT));
102102
switch (OperatingSystem.current()) {
103-
case LINUX:
104-
return lm; // All options are valid for Linux
103+
case LINUX: {
104+
// All options are valid for Linux, but VFORK is deprecated and results
105+
// in a warning
106+
if (lm == LaunchMechanism.VFORK) {
107+
System.err.println("VFORK MODE DEPRECATED");
108+
System.err.println("""
109+
The VFORK launch mechanism has been deprecated for being dangerous.
110+
It will be removed in a future java version. Either remove the
111+
jdk.lang.Process.launchMechanism property (preferred) or use FORK mode
112+
instead (-Djdk.lang.Process.launchMechanism=FORK).
113+
""");
114+
}
115+
return lm;
116+
}
105117
case AIX:
106118
case MACOS:
107119
if (lm != LaunchMechanism.VFORK) {
108120
return lm; // All but VFORK are valid
109121
}
110122
break;
111-
case WINDOWS:
112-
// fall through to throw to Error
113123
}
114124
} catch (IllegalArgumentException e) {
115125
}

0 commit comments

Comments
 (0)