From 80dc32094f7238b22ec36d1108b46ee68f7d10fd Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 12 Jan 2016 16:37:03 -0800 Subject: [PATCH 1/4] 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*); From e169d683c44fd4da827262835a2a57f5259c21b9 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 13 Jan 2016 08:14:22 -0700 Subject: [PATCH 2/4] fix Linux openjdk build regression --- openjdk-patches/Inet6AddressImpl.c.8.patch | 4 +++- openjdk-src.mk | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/openjdk-patches/Inet6AddressImpl.c.8.patch b/openjdk-patches/Inet6AddressImpl.c.8.patch index 2beb9763bf..d2994ea21f 100644 --- a/openjdk-patches/Inet6AddressImpl.c.8.patch +++ b/openjdk-patches/Inet6AddressImpl.c.8.patch @@ -1,14 +1,16 @@ --- openjdk/Inet6AddressImpl.c +++ openjdk/Inet6AddressImpl.c -@@ -360,6 +360,11 @@ +@@ -360,6 +360,13 @@ #ifdef AF_INET6 ++#ifdef __MINGW32__ +typedef struct icmpv6_echo_reply_lh { + IPV6_ADDRESS_EX Address; + ULONG Status; + unsigned int RoundTripTime; +} ICMPV6_ECHO_REPLY, *PICMPV6_ECHO_REPLY; ++#endif /** * ping implementation. diff --git a/openjdk-src.mk b/openjdk-src.mk index 4c14a0334f..0270de9a4d 100644 --- a/openjdk-src.mk +++ b/openjdk-src.mk @@ -314,6 +314,11 @@ else sun.nio.ch.InheritedChannel \ sun.nio.fs.UnixNativeDispatcher \ + ifneq (7,$(openjdk-version)) + openjdk-headers-classes += \ + jdk.net.SocketFlow + endif + openjdk-cflags += \ "-I$(openjdk-src)/solaris/javavm/export" \ "-I$(openjdk-src)/solaris/native/common" \ From 10eecce9cf72137f631bf7f5ab932da4ea1bd1b9 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 13 Jan 2016 09:03:48 -0700 Subject: [PATCH 3/4] add OSX 10.10 and 10.11 to SDK search list --- makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index 5a35677582..3f0ce03941 100755 --- a/makefile +++ b/makefile @@ -736,7 +736,9 @@ ifeq ($(kernel),darwin) sdk-dir = $(platform-dir)/Developer/SDKs mac-version := $(shell \ - if test -d $(sdk-dir)/MacOSX10.9.sdk; then echo 10.9; \ + if test -d $(sdk-dir)/MacOSX10.11.sdk; then echo 10.11; \ + elif test -d $(sdk-dir)/MacOSX10.10.sdk; then echo 10.10; \ + elif test -d $(sdk-dir)/MacOSX10.9.sdk; then echo 10.9; \ elif test -d $(sdk-dir)/MacOSX10.8.sdk; then echo 10.8; \ elif test -d $(sdk-dir)/MacOSX10.7.sdk; then echo 10.7; \ elif test -d $(sdk-dir)/MacOSX10.6.sdk; then echo 10.6; \ From dab9bb7d1f52e0d6af2bc030863bb6d1047d20ed Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 13 Jan 2016 09:28:07 -0800 Subject: [PATCH 4/4] replace preprocessor __try/__except hack with patch --- makefile | 3 +++ .../java_props_md.c.8.windows.patch | 24 +++++++++++++++++++ openjdk-src.mk | 4 +--- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 openjdk-patches/java_props_md.c.8.windows.patch diff --git a/makefile b/makefile index 3f0ce03941..e42c3e7f23 100755 --- a/makefile +++ b/makefile @@ -2278,6 +2278,9 @@ ifneq (7,$(openjdk-version)) if [ -f openjdk-patches/$(notdir $(<)).8.patch ]; then \ ( cd $(build) && patch -p0 ) < openjdk-patches/$(notdir $(<)).8.patch; \ fi + if [ -f openjdk-patches/$(notdir $(<)).8.$(platform).patch ]; then \ + ( cd $(build) && patch -p0 ) < openjdk-patches/$(notdir $(<)).8.$(platform).patch; \ + fi endif if [ -f openjdk-patches/$(notdir $(<)).patch ]; then \ ( cd $(build) && patch -p0 ) < openjdk-patches/$(notdir $(<)).patch; \ diff --git a/openjdk-patches/java_props_md.c.8.windows.patch b/openjdk-patches/java_props_md.c.8.windows.patch new file mode 100644 index 0000000000..0211421383 --- /dev/null +++ b/openjdk-patches/java_props_md.c.8.windows.patch @@ -0,0 +1,24 @@ +--- openjdk/java_props_md.c ++++ openjdk/java_props_md.c +@@ -212,17 +212,17 @@ + * SHELL32 DLL is delay load DLL and we can use the trick with + * __try/__except block. + */ +- __try { ++ /* __try { */ + /* + * For Windows Vista and later (or patched MS OS) we need to use + * [SHGetKnownFolderPath] call to avoid MAX_PATH length limitation. + * Shell32.dll (version 6.0.6000 or later) + */ + hr = SHGetKnownFolderPath(&FOLDERID_Profile, KF_FLAG_DONT_VERIFY, NULL, &u_path); +- } __except(EXCEPTION_EXECUTE_HANDLER) { ++ /* } __except(EXCEPTION_EXECUTE_HANDLER) { */ + /* Exception: no [SHGetKnownFolderPath] entry */ +- hr = E_FAIL; +- } ++ /* hr = E_FAIL; */ ++ /* } */ + + if (FAILED(hr)) { + WCHAR path[MAX_PATH+1]; diff --git a/openjdk-src.mk b/openjdk-src.mk index 0270de9a4d..f4ec22b9d0 100644 --- a/openjdk-src.mk +++ b/openjdk-src.mk @@ -252,9 +252,7 @@ ifeq ($(platform),windows) -D_JAVASOFT_WIN32_TYPEDEF_MD_H_ \ -D_WIN32_WINNT=0x0600 \ -Ds6_words=_s6_words \ - -Ds6_bytes=_s6_bytes \ - "-D__try=if (1)" \ - "-D__except(a)=else" + -Ds6_bytes=_s6_bytes ifeq ($(arch),x86_64) openjdk-cflags += "-I$(root)/win64/include"