changeset 24592:6c3b7ca0cb90

Fix Java >1.8 on macOS (Bug #9439) * configure.ac: Set up JAVA_CPPFLAGS in a manner consistent with Linux. * libinterp/octave-value/ov-java.cc: Remove all the CPP magic for macOS.
author Sebastian Schöps <sesc@gmx.de>
date Sat, 13 Jan 2018 10:27:11 -0800
parents bccb203494f6
children 7a0cf02ed6d5
files configure.ac libinterp/octave-value/ov-java.cc
diffstat 2 files changed, 2 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Fri Jan 12 10:20:31 2018 -0800
+++ b/configure.ac	Sat Jan 13 10:27:11 2018 -0800
@@ -2720,17 +2720,11 @@
   ## Java and JVM found.  Set up flags.
   case $host_os in
     darwin*)
-      ## Sneak the -framework flag into mkoctfile via LDFLAGS
-      LDFLAGS="$LDFLAGS -framework JavaVM"
-      ## According to: http://developer.apple.com/unix/crossplatform.html
-      ## one must explicitly set the include path.
-      ## Unfortunately, the include path keeps moving around.
       if test -n "$JAVA_CPPFLAGS"; then
-        JAVA_CPPFLAGS="-I${JAVA_CPPFLAGS}"
+        JAVA_CPPFLAGS="-I${JAVA_CPPFLAGS} -I${JAVA_CPPFLAGS}/darwin"
       else
-        JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I/System/Library/Frameworks/JavaVM.framework/Home/include -I/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers -I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers"
+        JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin"
       fi
-      JAVA_LIBS="-framework JavaVM"
     ;;
     *)
       if test -n "$JAVA_CPPFLAGS"; then
--- a/libinterp/octave-value/ov-java.cc	Fri Jan 12 10:20:31 2018 -0800
+++ b/libinterp/octave-value/ov-java.cc	Sat Jan 13 10:27:11 2018 -0800
@@ -641,8 +641,6 @@
   //! The number of created jvm's.
   jsize nVMs = 0;
 
-#if ! defined (__APPLE__) && ! defined (__MACH__)
-
   octave::dynamic_library lib (jvm_lib_path);
 
   if (! lib)
@@ -663,16 +661,6 @@
 
   if (get_vm (&jvm, 1, &nVMs) == 0 && nVMs > 0)
 
-#else
-
-  // FIXME: There exists a problem on the Mac platform that
-  //   octave::dynamic_library lib (jvm_lib_path)
-  // doesn't work with 'not-bundled' *.oct files.
-
-  if (JNI_GetCreatedJavaVMs (&jvm, 1, &nVMs) == 0 && nVMs > 0)
-
-#endif
-
     {
       // At least one JVM exists, try to attach the current thread to it.
 
@@ -717,24 +705,12 @@
                               octave::sys::file_ops::dir_sep_str () +
                               "java.opts");
 
-#if ! defined (__APPLE__) && ! defined (__MACH__)
-
       if (create_vm (&jvm, &current_env, vm_args.to_args ()) != JNI_OK)
         error ("unable to start Java VM in %s", jvm_lib_path.c_str ());
     }
 
   jvm_lib = lib;
 
-#else
-
-      if (JNI_CreateJavaVM (&jvm, reinterpret_cast<void **> (&current_env),
-                            vm_args.to_args ()) != JNI_OK)
-        error ("unable to start Java VM in %s", jvm_lib_path.c_str ());
-
-    }
-
-#endif
-
   setlocale (LC_ALL, locale.c_str ());
 }