8149780: GatherProcessInfoTimeoutHandler shouldn't call getWin32Pid if the lib isn't load
Reviewed-by: iignatyev, stsmirno
This commit is contained in:
parent
4b48aaa15e
commit
6061ff3f28
@ -39,12 +39,16 @@ import java.nio.file.Path;
|
|||||||
* process and its children.
|
* process and its children.
|
||||||
*/
|
*/
|
||||||
public class GatherProcessInfoTimeoutHandler extends TimeoutHandler {
|
public class GatherProcessInfoTimeoutHandler extends TimeoutHandler {
|
||||||
|
private static final boolean HAS_NATIVE_LIBRARY;
|
||||||
static {
|
static {
|
||||||
|
boolean value = true;
|
||||||
try {
|
try {
|
||||||
System.loadLibrary("timeoutHandler");
|
System.loadLibrary("timeoutHandler");
|
||||||
} catch (UnsatisfiedLinkError ignore) {
|
} catch (UnsatisfiedLinkError ignore) {
|
||||||
// not all os need timeoutHandler native-library
|
// not all os need timeoutHandler native-library
|
||||||
|
value = false;
|
||||||
}
|
}
|
||||||
|
HAS_NATIVE_LIBRARY = value;
|
||||||
}
|
}
|
||||||
private static final String LOG_FILENAME = "processes.log";
|
private static final String LOG_FILENAME = "processes.log";
|
||||||
private static final String OUTPUT_FILENAME = "processes.html";
|
private static final String OUTPUT_FILENAME = "processes.html";
|
||||||
@ -105,7 +109,7 @@ public class GatherProcessInfoTimeoutHandler extends TimeoutHandler {
|
|||||||
if (result == 0L) {
|
if (result == 0L) {
|
||||||
/* jtreg didn't find pid, most probably we are on JDK < 9
|
/* jtreg didn't find pid, most probably we are on JDK < 9
|
||||||
there is no Process::getPid */
|
there is no Process::getPid */
|
||||||
if ("windows".equals(OS.current().family)) {
|
if (HAS_NATIVE_LIBRARY && "windows".equals(OS.current().family)) {
|
||||||
try {
|
try {
|
||||||
Field field = process.getClass().getDeclaredField("handle");
|
Field field = process.getClass().getDeclaredField("handle");
|
||||||
boolean old = field.isAccessible();
|
boolean old = field.isAccessible();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user