8268626: Remove native pre-jdk9 support for jtreg failure handler
Reviewed-by: erikj
This commit is contained in:
parent
e59acd9860
commit
2e70bc35df
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -60,24 +60,6 @@ $(eval $(call SetupJavaCompilation, BUILD_FAILURE_HANDLER, \
|
||||
|
||||
TARGETS += $(BUILD_FAILURE_HANDLER)
|
||||
|
||||
################################################################################
|
||||
|
||||
ifeq ($(call isTargetOs, windows), true)
|
||||
|
||||
$(eval $(call SetupNativeCompilation, BUILD_LIBTIMEOUT_HANDLER, \
|
||||
NAME := timeoutHandler, \
|
||||
SRC := $(FH_BASEDIR)/src/windows/native/libtimeoutHandler, \
|
||||
OBJECT_DIR := $(FH_SUPPORT)/libtimeoutHandler, \
|
||||
OUTPUT_DIR := $(FH_SUPPORT), \
|
||||
CFLAGS := $(CFLAGS_JDKLIB), \
|
||||
LDFLAGS := $(LDFLAGS_JDKLIB), \
|
||||
OPTIMIZATION := LOW, \
|
||||
))
|
||||
|
||||
TARGETS += $(BUILD_LIBTIMEOUT_HANDLER)
|
||||
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# Targets for building test-image.
|
||||
################################################################################
|
||||
@ -99,10 +81,6 @@ IMAGES_TARGETS += $(COPY_FH)
|
||||
# Use JTREG_TESTS for jtreg tests parameter
|
||||
#
|
||||
RUN_DIR := $(FH_SUPPORT)/test
|
||||
# Add the dir of the dll to the path on windows
|
||||
ifeq ($(call isTargetOs, windows), true)
|
||||
export PATH := $(PATH);$(FH_SUPPORT)
|
||||
endif
|
||||
|
||||
test:
|
||||
$(RM) -r $(RUN_DIR)
|
||||
|
@ -53,19 +53,10 @@ SRC_DIR := $(shell cygpath -m "${SRC_DIR}")
|
||||
JAVA_HOME := $(shell cygpath -m "${JAVA_HOME}")
|
||||
JTREG_HOME := $(shell cygpath -m "${JTREG_HOME}")
|
||||
CLASSPATH := $(shell cygpath -pm "${CLASSPATH}")
|
||||
CC := "cl.exe"
|
||||
endif
|
||||
|
||||
all: clean test
|
||||
|
||||
native: require_env
|
||||
ifeq ("${OS_NAME}", "Cygwin")
|
||||
"${CC}" src/windows/native/jdk/test/failurehandler/jtreg/*.c \
|
||||
-I"$(shell cygpath -w "${JAVA_HOME}/include")" \
|
||||
-I"$(shell cygpath -w "${JAVA_HOME}/include/win32")" \
|
||||
/link /DLL /OUT:timeoutHandler.dll
|
||||
endif
|
||||
|
||||
check_defined = $(foreach 1,$1,$(__check_defined))
|
||||
__check_defined = $(if $(value $1),, $(error $1 is not set))
|
||||
|
||||
@ -112,7 +103,7 @@ require_env:
|
||||
clean:
|
||||
rm -rf "${BUILD_DIR}" "${RUN_DIR}"
|
||||
|
||||
build: classes native
|
||||
build: classes
|
||||
|
||||
.PHONY: all build classes native test require_env clean
|
||||
.PHONY: all build classes test require_env clean
|
||||
.DEFAULT: all
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,7 +30,6 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
@ -102,33 +101,6 @@ public class GatherProcessInfoTimeoutHandler extends TimeoutHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long getProcessId(Process process) {
|
||||
long result = super.getProcessId(process);
|
||||
if (result == 0L) {
|
||||
/* jtreg didn't find pid, most probably we are on JDK < 9
|
||||
there is no Process::getPid */
|
||||
if (HAS_NATIVE_LIBRARY && "windows".equals(OS.current().family)) {
|
||||
try {
|
||||
Field field = process.getClass().getDeclaredField("handle");
|
||||
boolean old = field.canAccess(process);
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
long handle = field.getLong(process);
|
||||
result = getWin32Pid(handle);
|
||||
} finally {
|
||||
field.setAccessible(old);
|
||||
}
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private native long getWin32Pid(long handle);
|
||||
|
||||
private void runGatherer(String name, Path workDir, PrintWriter log,
|
||||
PrintWriter out, long pid) {
|
||||
try (HtmlPage html = new HtmlPage(out)) {
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_jdk_test_failurehandler_jtreg_GatherProcessInfoTimeoutHandler_getWin32Pid
|
||||
(JNIEnv* env, jobject o, jlong handle) {
|
||||
return GetProcessId((HANDLE) handle);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user