From 80dc32094f7238b22ec36d1108b46ee68f7d10fd Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 12 Jan 2016 16:37:03 -0800 Subject: [PATCH] fix openjdk/openjdk-src builds for latest JDKs 7 and 8 The tower of patches and hacks grows higher. Ideally, we'll just drop support for JDK 7 soon and clean this mess up a bit, but TravisCI still hasn't gotten the memo that it's dead, so we muddle onward. I've tested this on Windows, but not yet Linux or OS X. Wanted to get a PR before I move on to that. --- makefile | 19 ++++++++++--- openjdk-patches/Inet6AddressImpl.c.8.patch | 15 ++++++++++ openjdk-src.mk | 28 +++++++++++++++---- src/classpath-openjdk.cpp | 32 +++++++++++++++++++++- 4 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 openjdk-patches/Inet6AddressImpl.c.8.patch diff --git a/makefile b/makefile index a7f39a8879..5a35677582 100755 --- a/makefile +++ b/makefile @@ -166,6 +166,10 @@ library-path = $(library-path-variable)=$(build) ifneq ($(openjdk),) + openjdk-version := $(shell $(openjdk)/bin/java -version 2>&1 \ + | head -n 1 \ + | sed 's/.*version "1.\([^.]*\).*/\1/') + openjdk-arch = $(arch) ifeq ($(arch),x86_64) openjdk-arch = amd64 @@ -832,12 +836,12 @@ ifeq ($(kernel),darwin) cflags += $(flags) asmflags += $(flags) lflags += $(flags) - + ios-version-min=$(ios-version) ifdef ios_deployment_target ios-version-min=ios_deployment_target endif - + ifeq ($(sim),true) ifeq ($(arch),x86_64) classpath-extra-cflags += \ @@ -875,7 +879,7 @@ ifeq ($(kernel),darwin) asmflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION} lflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION} endif - + ifeq ($(arch),x86_64) classpath-extra-cflags += -arch x86_64 cflags += -arch x86_64 @@ -904,7 +908,9 @@ ifeq ($(platform),windows) exe-suffix = .exe rpath = - lflags = -L$(lib) $(common-lflags) -lws2_32 -liphlpapi -mconsole + lflags = -L$(lib) $(common-lflags) -lws2_32 -lversion -luuid -liphlpapi \ + -lmswsock -mconsole + cflags = -I$(inc) $(common-cflags) -DWINVER=0x0500 -U__STRICT_ANSI__ ifeq (,$(filter mingw32 cygwin,$(build-platform))) @@ -2265,6 +2271,11 @@ ifeq ($(platform),ios) < "$(openjdk-src)/solaris/native/java/lang/childproc.h" \ > $(build)/openjdk/childproc.h; \ fi +endif +ifneq (7,$(openjdk-version)) + if [ -f openjdk-patches/$(notdir $(<)).8.patch ]; then \ + ( cd $(build) && patch -p0 ) < openjdk-patches/$(notdir $(<)).8.patch; \ + fi endif if [ -f openjdk-patches/$(notdir $(<)).patch ]; then \ ( cd $(build) && patch -p0 ) < openjdk-patches/$(notdir $(<)).patch; \ diff --git a/openjdk-patches/Inet6AddressImpl.c.8.patch b/openjdk-patches/Inet6AddressImpl.c.8.patch new file mode 100644 index 0000000000..2beb9763bf --- /dev/null +++ b/openjdk-patches/Inet6AddressImpl.c.8.patch @@ -0,0 +1,15 @@ +--- openjdk/Inet6AddressImpl.c ++++ openjdk/Inet6AddressImpl.c +@@ -360,6 +360,11 @@ + + #ifdef AF_INET6 + ++typedef struct icmpv6_echo_reply_lh { ++ IPV6_ADDRESS_EX Address; ++ ULONG Status; ++ unsigned int RoundTripTime; ++} ICMPV6_ECHO_REPLY, *PICMPV6_ECHO_REPLY; + + /** + * ping implementation. + diff --git a/openjdk-src.mk b/openjdk-src.mk index f357df6520..4c14a0334f 100644 --- a/openjdk-src.mk +++ b/openjdk-src.mk @@ -49,7 +49,6 @@ openjdk-sources = \ $(openjdk-src)/share/native/java/util/zip/zip_util.c \ $(openjdk-src)/share/native/sun/management/VMManagementImpl.c \ $(openjdk-src)/share/native/sun/misc/GC.c \ - $(openjdk-src)/share/native/sun/misc/URLClassPath.c \ $(openjdk-src)/share/native/sun/misc/MessageUtils.c \ $(openjdk-src)/share/native/sun/misc/NativeSignalHandler.c \ $(openjdk-src)/share/native/sun/misc/Signal.c \ @@ -143,6 +142,11 @@ openjdk-headers-classes = \ sun.reflect.Reflection \ sun.security.provider.NativeSeedGenerator +ifneq (7,$(openjdk-version)) + openjdk-sources += \ + $(openjdk-src)/share/native/sun/misc/URLClassPath.c +endif + # todo: set properties according to architecture targeted and OpenJDK # version used: openjdk-cflags = \ @@ -181,15 +185,14 @@ ifeq ($(platform),windows) $(openjdk-src)/windows/native/java/io/FileDescriptor_md.c \ $(openjdk-src)/windows/native/java/io/FileInputStream_md.c \ $(openjdk-src)/windows/native/java/io/FileOutputStream_md.c \ - $(openjdk-src)/windows/native/java/io/FileSystem_md.c \ $(openjdk-src)/windows/native/java/io/io_util_md.c \ $(openjdk-src)/windows/native/java/io/RandomAccessFile_md.c \ - $(openjdk-src)/windows/native/java/io/Win32FileSystem_md.c \ $(openjdk-src)/windows/native/java/io/WinNTFileSystem_md.c \ $(openjdk-src)/windows/native/java/lang/java_props_md.c \ $(openjdk-src)/windows/native/java/lang/ProcessEnvironment_md.c \ $(openjdk-src)/windows/native/java/lang/ProcessImpl_md.c \ $(openjdk-src)/windows/native/java/net/net_util_md.c \ + $(openjdk-src)/windows/native/java/net/ExtendedOptionsImpl.c \ $(openjdk-src)/windows/native/java/net/DualStackPlainSocketImpl.c \ $(openjdk-src)/windows/native/java/net/InetAddressImplFactory.c \ $(openjdk-src)/windows/native/java/net/Inet4AddressImpl.c \ @@ -218,6 +221,12 @@ ifeq ($(platform),windows) $(openjdk-src)/windows/native/sun/nio/fs/WindowsNativeDispatcher.c \ $(openjdk-src)/windows/native/sun/security/provider/WinCAPISeedGenerator.c + ifeq (7,$(openjdk-version)) + openjdk-sources += \ + $(openjdk-src)/windows/native/java/io/FileSystem_md.c \ + $(openjdk-src)/windows/native/java/io/Win32FileSystem_md.c + endif + openjdk-headers-classes += \ java.net.DualStackPlainSocketImpl \ java.net.SocketImpl \ @@ -236,14 +245,22 @@ ifeq ($(platform),windows) "-I$(openjdk-src)/windows/native/java/util" \ "-I$(openjdk-src)/windows/native/sun/nio/ch" \ "-I$(openjdk-src)/windows/javavm/include" \ - "-I$(root)/win32/include" \ -DLOCALE_SNAME=0x0000005c \ -DLOCALE_SISO3166CTRYNAME2=0x00000068 \ -DLOCALE_SISO639LANGNAME2=0x00000067 \ -D_JNI_IMPLEMENTATION_ \ -D_JAVASOFT_WIN32_TYPEDEF_MD_H_ \ + -D_WIN32_WINNT=0x0600 \ -Ds6_words=_s6_words \ - -Ds6_bytes=_s6_bytes + -Ds6_bytes=_s6_bytes \ + "-D__try=if (1)" \ + "-D__except(a)=else" + + ifeq ($(arch),x86_64) + openjdk-cflags += "-I$(root)/win64/include" + else + openjdk-cflags += "-I$(root)/win32/include" + endif else openjdk-sources += \ $(shell find $(openjdk-src)/solaris/native/common -name '*.c') \ @@ -261,6 +278,7 @@ else $(openjdk-src)/solaris/native/java/lang/ProcessEnvironment_md.c \ $(openjdk-src)/solaris/native/java/lang/UNIXProcess_md.c \ $(openjdk-src)/solaris/native/java/net/net_util_md.c \ + $(openjdk-src)/solaris/native/java/net/ExtendedOptionsImpl.c \ $(openjdk-src)/solaris/native/java/net/InetAddressImplFactory.c \ $(openjdk-src)/solaris/native/java/net/Inet4AddressImpl.c \ $(openjdk-src)/solaris/native/java/net/Inet6AddressImpl.c \ diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 5cbed68a1a..264b6cf33b 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -662,7 +662,10 @@ class MyClasspath : public Classpath { #ifdef AVIAN_OPENJDK_SRC interceptFileOperations(t, true); #else // not AVIAN_OPENJDK_SRC - expect(t, loadLibrary(t, libraryPath, "verify", true, true)); +# ifdef PLATFORM_WINDOWS + expect(t, loadLibrary(t, libraryPath, "msvcr100", true, true)); +# endif + expect(t, loadLibrary(t, libraryPath, "verify", true, true)); expect(t, loadLibrary(t, libraryPath, "java", true, true)); #endif // not AVIAN_OPENJDK_SRC @@ -3122,6 +3125,11 @@ namespace { namespace local { +extern "C" AVIAN_EXPORT jobjectArray JNICALL EXPORT(JVM_GetMethodParameters)(Thread*, jobject) +{ + abort(); +} + extern "C" AVIAN_EXPORT jint JNICALL EXPORT(JVM_GetInterfaceVersion)() { return local::InterfaceVersion; @@ -5972,6 +5980,28 @@ extern "C" void* JDK_FindJvmEntry(const char* name) return voidPointer(GetProcAddress(jvmHandle, name)); } +extern "C" HMODULE JDK_LoadSystemLibrary(const char* name) { + HMODULE handle; + char path[MAX_PATH]; + + if (GetSystemDirectory(path, sizeof(path)) != 0) { + strcat(path, "\\"); + strcat(path, name); + handle = LoadLibrary(path); + } else { + handle = nullptr; + } + + if (handle == nullptr) { + if (GetWindowsDirectory(path, sizeof(path)) != 0) { + strcat(path, "\\"); + strcat(path, name); + handle = LoadLibrary(path); + } + } + return handle; +} + #ifdef AVIAN_OPENJDK_SRC extern "C" char* findJavaTZ_md(const char*, const char*);