Package org.apache.maven.surefire.booter
Class SystemUtils
java.lang.Object
org.apache.maven.surefire.booter.SystemUtils
JDK 9 support.
- Since:
- 2.20.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
endsWithJavaPath
(String jvmExecPath) static boolean
static boolean
isJava9AtLeast
(String jvmExecutablePath) static boolean
isJava9AtLeast
(BigDecimal version) static Long
pid()
(package private) static Long
(package private) static Long
pidOnJMX()
(package private) static Long
The process status.(package private) static Long
pidStatusOnBSD
(String root) For testing purposes only.(package private) static Long
$ cat /proc/self/stat
48982 (cat) R 9744 48982 9744 34818 48982 8192 185 0 0 0 0 0 0 0 20 0 1 0 137436614 103354368 134 18446744073709551615 4194304 4235780 140737488346592 140737488343784 252896458544 0 0 0 0 0 0 0 17 2 0 0 0 0 0
$ SELF_PID=$(cat /proc/self/stat)
$ echo $CPU_ID | gawk '{print $1}'
48982(package private) static Long
pidStatusOnLinux
(String root) For testing purposes only.static ClassLoader
(package private) static ClassLoader
reflectClassLoader
(Class<?> target, String getterMethodName) static File
If system propertyjava.home
is/jdk
(since jdk9) or/jdk/jre
(prior to jdk9) then the absolute path to JDK home is returned/jdk
.(package private) static File
toJdkHomeFromJre
(String jreHome) IfjreHome
is/jdk
(since jdk9) or/jdk/jre
(prior to jdk9) then the absolute path to JDK home is returned/jdk
.static File
toJdkHomeFromJvmExec
(String jvmExecutable) IfjvmExecutable
is/jdk/bin/java
(since jdk9) or/jdk/jre/bin/java
(prior to jdk9) then the absolute path to JDK home is returned/jdk
.static BigDecimal
toJdkVersionFromReleaseFile
(File jdkHome)
-
Field Details
-
JIGSAW_JAVA_VERSION
-
PROC_STATUS_PID_FIRST_CHARS
private static final int PROC_STATUS_PID_FIRST_CHARS- See Also:
-
-
Constructor Details
-
SystemUtils
private SystemUtils()
-
-
Method Details
-
endsWithJavaPath
- Parameters:
jvmExecPath
- e.g. /jdk/bin/java, /jdk/jre/bin/java- Returns:
true
ifjvmExecPath
is path to java binary executor
-
toJdkHomeFromJvmExec
IfjvmExecutable
is/jdk/bin/java
(since jdk9) or/jdk/jre/bin/java
(prior to jdk9) then the absolute path to JDK home is returned/jdk
.
Null is returned ifjvmExecutable
is incorrect.- Parameters:
jvmExecutable
- /jdk/bin/java* or /jdk/jre/bin/java*- Returns:
- path to jdk directory; or
null
if wrong path or directory layout of JDK installation.
-
toJdkHomeFromJre
If system propertyjava.home
is/jdk
(since jdk9) or/jdk/jre
(prior to jdk9) then the absolute path to JDK home is returned/jdk
.- Returns:
- path to JDK
-
toJdkHomeFromJre
IfjreHome
is/jdk
(since jdk9) or/jdk/jre
(prior to jdk9) then the absolute path to JDK home is returned/jdk
.
JRE home directoryjreHome
must be taken from system propertyjava.home
.- Parameters:
jreHome
- path to /jdk or /jdk/jre- Returns:
- path to JDK
-
toJdkVersionFromReleaseFile
-
isJava9AtLeast
-
isBuiltInJava9AtLeast
public static boolean isBuiltInJava9AtLeast() -
isJava9AtLeast
-
platformClassLoader
-
pid
-
pidOnJMX
-
pidStatusOnLinux
$ cat /proc/self/stat
48982 (cat) R 9744 48982 9744 34818 48982 8192 185 0 0 0 0 0 0 0 20 0 1 0 137436614 103354368 134 18446744073709551615 4194304 4235780 140737488346592 140737488343784 252896458544 0 0 0 0 0 0 0 17 2 0 0 0 0 0
$ SELF_PID=$(cat /proc/self/stat)
$ echo $CPU_ID | gawk '{print $1}'
48982- Returns:
- self PID
- Throws:
Exception
- i/o and number format exc
-
pidStatusOnLinux
For testing purposes only.- Parameters:
root
- shifted to test-classes- Returns:
- same as in
pidStatusOnLinux()
- Throws:
Exception
- same as inpidStatusOnLinux()
-
pidStatusOnBSD
The process status. This file is read-only and returns a single line containing multiple space-separated fields.
See procfs status
# cat /proc/curproc/status
cat 60424 60386 60424 60386 5,0 ctty 972854153,236415 0,0 0,1043 nochan 0 0 0,0 prisoner
Fields are:
comm pid ppid pgid sid maj, min ctty, sldr start user/system time wmsg euid ruid rgid,egid, groups[1 .. NGROUPS] hostname- Returns:
- current PID
- Throws:
Exception
- if could not read /proc/curproc/status
-
pidStatusOnBSD
For testing purposes only.- Parameters:
root
- shifted to test-classes- Returns:
- same as in
pidStatusOnBSD()
- Throws:
Exception
- same as inpidStatusOnBSD()
-
pidOnJava9
-
reflectClassLoader
-