patchGNU Octave - Patches: patch #9439, Fix Java >1.8 on Mac

 
 

patch #9439: Fix Java >1.8 on Mac

Submitter:  None
Submitted:  Sun 20 Aug 2017 11:54:33 AM UTC
   
 
Category:  Core : other Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  bpabbott Originator Email:  -email is unavailable-
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 01 Feb 2018 03:11:23 PM UTC, comment #36: 

@Sebastian,

I get the same. Dialog attached.


Ben Abbott <bpabbott>
Group Member
Wed 31 Jan 2018 10:27:57 AM UTC, comment #35: 

Can someone please confirm what happens if you execute 'usejava ("awt")' in Octave on macOS with Java >1.8? (in my case it asks to install the outdate Java 1.6 which is bad...)

Thanks,
Sebastian



Sebastian <sschoeps>
Wed 17 Jan 2018 05:52:48 AM UTC, comment #34: 

Per Ben Abbott's request, I can verify this works with Java 9 on High Sierra for me also. See the output below.

octave:3> javaclasspath
   STATIC JAVA PATH

      - empty -

   DYNAMIC JAVA PATH

      - empty -

octave:4> class  = 'java.lang.String';
octave:5> text = 'hello';
octave:6> strObj = javaObject(class, text);
octave:7> whos
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        ans         1x1                          8  double
        class       1x16                        16  char
        strObj      1x1                          0  java.lang.String
        text        1x5                          5  char

Total is 23 elements using 29 bytes

John Swensen <jpswensen>
Sun 14 Jan 2018 03:42:13 PM UTC, comment #33: 
Ben Abbott <bpabbott>
Group Member
Sat 13 Jan 2018 04:11:47 PM UTC, comment #32: 

Essentially, the JAVA_CPPFLAGS are the same as for linux, with "linux" replaced by "darwin". As with Linux, JAVA_LIBS is empty, and there are no changes to LDFLAGS.

Ben Abbott <bpabbott>
Group Member
Sat 13 Jan 2018 10:59:55 AM UTC, comment #31: 

Yes, file #42899 works for me (I tested my favourite example from here http://wiki.octave.org/Cookbook#Load_XML_files). I did not have the time to look at the changes in the patch. What did you do? Just cleaning up the path? Thanks!

Sebastian <sschoeps>
Sat 13 Jan 2018 05:55:45 AM UTC, comment #30: 

@Sebastian,

I'm attaching a changeset that works for me. Please confirm it works for you as well. This is essentially you patch with the include paths trimmed down.


(file #42899)

Ben Abbott <bpabbott>
Group Member
Sat 13 Jan 2018 03:05:44 AM UTC, comment #29: 

@Sebastian

I uninstalled /Library/Java/JavaVirtualMachines/1.6.0.jdk and although Octave still configures with Java Support, I also encounter the dialog you attached .

I then used (file #42102) and Octave configured with Java support, and ran without the dialog showing up.

I'd hoped to use the Oracle approach to select the Java version, and would prefer to allow Octave to configure without specifying a lot of detail.

I'll tinker a bit more, but expect to push a changeset soon.

Ben Abbott <bpabbott>
Group Member
Fri 12 Jan 2018 02:31:02 AM UTC, comment #28: 

The -source and -target options are correct (so that bytecode is compiled in a backwards compatible way) and the Note diagnostics printed are the same on GNU/Linux with Java 8. These are warnings that have showed up since the -source and -target were updated to 1.6 that haven't been addressed in the Java source code yet.

Mike Miller <mtmiller>
Group Member
Fri 12 Jan 2018 01:57:03 AM UTC, comment #27: 

@Sebastian

I just noticed the following while building Octave.


build-aux/install-sh -c -d scripts/java/org/octave && \
        ( cd ./scripts/java; \
          "/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin/javac" -source 1.6 -target 1.6 -Xlint:-options \
                     -d /Users/bpabbott/Development/mercurial/default/sources/scripts/java \
                     org/octave/ClassHelper.java )
Note: org/octave/ClassHelper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: org/octave/ClassHelper.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
build-aux/install-sh -c -d scripts/java/org/octave && \
        ( cd ./scripts/java; \
          "/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin/javac" -source 1.6 -target 1.6 -Xlint:-options \
                     -d /Users/bpabbott/Development/mercurial/default/sources/scripts/java \
                     org/octave/Matrix.java )
build-aux/install-sh -c -d scripts/java/org/octave && \
        ( cd ./scripts/java; \
          "/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin/javac" -source 1.6 -target 1.6 -Xlint:-options \
                     -d /Users/bpabbott/Development/mercurial/default/sources/scripts/java \
                     org/octave/Octave.java )
Note: ./org/octave/OctaveReference.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: org/octave/Octave.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.


The "-source 1.6 -target 1.6" looks to indicate v1.6 of JavaVM is being used. I don't know what to think about the "Note"s.

Ben Abbott <bpabbott>
Group Member
Thu 11 Jan 2018 02:34:56 PM UTC, comment #26: 

@Sebastian

My configure finds ...

  Java home:                     /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
  Java JVM path:                 /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/server
  Java CPPFLAGS:                 -I/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/include/darwin -I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers
  Java libraries:                -Wl,-framework,JavaVM


Does your configure report the same?

I'd thought it was easy to switch between java versions, even if multiple versions are installed.

https://wimdeblauwe.wordpress.com/2014/03/20/switching-easily-between-java-jdks-on-mac-os-x/

I have 1.6, 1.8, and 9 installed, and have JAVA_HOME pointing to 9.

Ben Abbott <bpabbott>
Group Member
Thu 11 Jan 2018 12:48:57 PM UTC, comment #25: 

@Ben:

your patch does work in the sense that I can compile octave with Java. However, on start, I have to install the old and outdated Java SE6 framework from Apple. We should avoid this as Java SE6 is not maintained anymore and probably one big security issue. Screenshot attached.





Sebastian <sschoeps>
Wed 10 Jan 2018 02:15:41 PM UTC, comment #24: 

@Sebastian,

I spent more time looking at configure.ac, and found that if darwin is treated like linux, but with the Framework added, Java works. Below is the snippet from configure.ac.

2685   if test -z "$JAVA_LDPATH"; then
2686     ## Java failed to find it's own library path.  Guess wildly.
2687     JAVA_TMP_LDPATH=`ls -d $JAVA_HOME/jre/lib/*/client`
2688     JAVA_TMP_LDPATH="${JAVA_TMP_LDPATH} `ls -d $JAVA_HOME/jre/lib/*/server`"
2689     ## Add some paths that might work on Macs.
2690     JAVA_TMP_LDPATH="${JAVA_TMP_LDPATH} ${JAVA_HOME}/../Libraries ${JAVA_HOME}/Libraries"
2691     ## Add some paths that might work on MinGW
2692     JAVA_TMP_LDPATH="${JAVA_TMP_LDPATH} ${JAVA_HOME}/bin/client ${JAVA_HOME}/bin/server"
2693     for dir in $JAVA_TMP_LDPATH; do
2694       if test -f "$dir/$jvmlib"; then
2695         JAVA_LDPATH=$dir
2696         break
2697       fi
2698     done
2699   fi

I'm attaching a new patch (octave_devel_mac_java8.patch).

(file #42883)

Ben Abbott <bpabbott>
Group Member
Tue 21 Nov 2017 07:57:27 AM UTC, comment #23: 

@Ben:

if you do not care about the gui, then you do not need the extra steps explained in my blog post. Installing homebrew and then "brew install octave --with-java" is enough (please contact me if you need help to install homebrew somewhere else then /usr/local/).

Sebastian <sschoeps>
Tue 21 Nov 2017 01:08:47 AM UTC, comment #22: 

@Sebastian,

To try the default branch using home-brew, do I follow the instructions at the link below?

http://www.schoeps.org/home/2017/10/octave-on-macos-with-gui/

Regarding including "Wl,-framework,JavaVM"" in JAVA_LIBS, the framework would be removed from LDFLAGS.

Ben

Ben Abbott <bpabbott>
Group Member
Mon 20 Nov 2017 09:31:09 PM UTC, comment #21: 

@Ben: maybe you could install homebrew to see if that works for you?

>The text below is from you configure log attached to comment #11.


> Java home:                   
>/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
> Java JVM path:               
>/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/server
> Java CPPFLAGS:               
>-I/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/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 libraries:               
>
>After installing Java, I do not see a "Home" directory in
>"/System/Library/Frameworks/JavaVM.framework/". I don't expect including a
>non-existent directory will break anything, but either our Java installs have
>produced different results, or the patch should be cleaned up. Would you
>verify this directory exists for you (I'm running macOS High Sierra -
>10.13.1).


I agree, some of the includes are superfluous. They are hardcoded in configure.ac.
I did not change them because older macOS systems might still install stuff there.
Probably it's ok to erase them. I do not have "/System/Library/Frameworks/JavaVM.framework/Home" nor "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/". However, "/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/" is a match.

>Also, shouldn't the Java framework (i.e. "-Wl,-framework,JavaVM") be specified
>in "Java libraries"?


Sorry don't know. I do not seem to need it.

Sebastian

Sebastian <sschoeps>
Mon 20 Nov 2017 09:18:30 PM UTC, comment #20: 

@Sebastian

I also do not have have a CurrentJDK directory which I see in your config.log, i.e. "-I/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers" directory.

Ben Abbott <bpabbott>
Group Member
Mon 20 Nov 2017 08:56:37 PM UTC, comment #19: 

@Sebastian

Also there is a difference in the JAVA_CPPFLAGS for Linux and Darwin. For Linux ...


JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"


Should Darwin's also include the "darwin" directory in ${JAVA_HOME}/include? i.e.


JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/darwin -I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers"


Ben

Ben Abbott <bpabbott>
Group Member
Mon 20 Nov 2017 08:45:21 PM UTC, comment #18: 

@Sebastian

I'm still not able to get Java working, but have some comments/questions about the proposed patch.

The text below is from you configure log attached to comment #11.


  Java home:                     /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
  Java JVM path:                 /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/server
  Java CPPFLAGS:                 -I/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/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 libraries:


After installing Java, I do not see a "Home" directory in "/System/Library/Frameworks/JavaVM.framework/". I don't expect including a non-existent directory will break anything, but either our Java installs have produced different results, or the patch should be cleaned up. Would you verify this directory exists for you (I'm running macOS High Sierra - 10.13.1).

Also, shouldn't the Java framework (i.e. "-Wl,-framework,JavaVM") be specified in "Java libraries"?

Ben Abbott <bpabbott>
Group Member
Sat 14 Oct 2017 03:14:56 PM UTC, comment #17: 

ugh! When I tried to confirm by bootstrap -> configure -> make -> ./run-octave -> foo = javaclasspath() the SEGV is still present.

Its likely I forgot the bootstrap while debugging.

Ben Abbott <bpabbott>
Group Member
Sat 14 Oct 2017 12:26:20 PM UTC, comment #16: 

So you can confirm that Java works for you on Mac OS with this patch? If yes, then Mike could push it, right?

Bye
Sebastian

Sebastian <sschoeps>
Sat 14 Oct 2017 12:21:33 PM UTC, comment #15: 

Clarification, I no longer get the "AddressSanitizer: SEGV on unknown address" error when using Qt4 on macOS when the address sanitizer is disabled.

Ben Abbott <bpabbott>
Group Member
Sat 14 Oct 2017 12:20:26 PM UTC, comment #14: 

Opps. After checking again the ASAN_OPTIONS change to run-octave.in does not have any effect. I must have inadvertently bungled my period test.

Ben Abbott <bpabbott>
Group Member
Fri 13 Oct 2017 07:34:00 PM UTC, comment #13: 

I adjusted the patch and am now able to run the GUI using qt4 on macOS.

The trick was to set and export ASAN_OPTIONS to an empty string when the address sanitizer wasn't being used.


diff --git a/run-octave.in b/run-octave.in
--- a/run-octave.in
+++ b/run-octave.in
@@ -111,8 +111,11 @@ OCTAVE_SITE_INITFILE="$top_srcdir/script
 OCTAVE_VERSION_INITFILE="$top_srcdir/scripts/startup/version-rcfile"; export OCTAVE_VERSION_INITFILE

 if [ "$ADDRESS_SANITIZER_ENABLED" = yes ]; then
-  ASAN_OPTIONS=symbolize=1; export ASAN_OPTIONS
+  ASAN_OPTIONS=symbolize=1
+else
+  ASAN_OPTIONS=
 fi
+export ASAN_OPTIONS

 exec $builddir/libtool --mode=execute $driver \
   "$octave_executable" --no-init-path --path="$LOADPATH" \


(file #42139)

Ben Abbott <bpabbott>
Group Member
Tue 10 Oct 2017 01:27:11 PM UTC, comment #12: 

Ok. Thanks. I don't think I'm doing anything to introduce the address sanitizer.


ASAN:DEADLYSIGNAL
=================================================================
==64607==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00012d6d74f3 bp 0x000122bb906c sp 0x700003c54398 T6)
    #0 0x12d6d74f2  (<unknown module>)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (<unknown module>)
Thread T6 created by T0 here:
    #0 0x1117f2e29 in wrap_pthread_create (libclang_rt.asan_osx_dynamic.dylib+0x41e29)
    #1 0x10ce98a25 in QThread::start(QThread::Priority) (QtCore+0x23a25)
    #2 0x10a401b5b in main_window::main_window(QWidget*, octave::gui_application*) main-window.cc:228
    #3 0x10a42d3c1 in octave::gui_application::execute() octave-gui.cc:228
    #4 0x10a39561f in main main-gui.cc:104
    #5 0x7fff58c38144 in start (libdyld.dylib+0x1144)
    #6 0x8  (<unknown module>)

==64607==ABORTING
Abort trap: 6


From the summary, it looks to me as if my Qt4 was compiled with the AddressSanitizer enabled.

I'll ask the Fink support team if this is the case, and if it can be disabled.

Ben Abbott <bpabbott>
Group Member
Tue 10 Oct 2017 07:18:29 AM UTC, comment #11: 

@Ben: I can compile and run octave-devel with clang ("Apple LLVM version 9.0.0 (clang-900.0.37)") on High Sierra and the patch attached (actually I also apply the gui patch from https://savannah.gnu.org/bugs/?50025). I use Apple's BLAS (therefore one needs the library "veclibfort")

This is my configure string

./configure --prefix=/usr/local/octave/ --disable-dependency-tracking --disable-silent-rules --enable-link-all-dependencies --enable-shared --disable-static --disable-docs --without-OSMesa --with-hdf5-includedir=/usr/local/opt/hdf5/include --with-hdf5-libdir=/usr/local/opt/hdf5/lib --with-x=no --with-blas=-L/usr/local/opt/veclibfort/lib -lvecLibFort --with-portaudio --with-sndfile

Some version numbers of dependencies: arpack 3.5.0, fftw 3.3.6, java 9+181, qhull 2015.2, qrupdate 1.1.2, qscintilla2 2.10.1, qt 5.9.1, suite-sparse 4.5.5, sundials 2.7.0. Find the configure report attached.

Then, without crash...

>> javaclasspath

   STATIC JAVA PATH

      - empty -

   DYNAMIC JAVA PATH

      - empty -


(file #42108)

Sebastian <sschoeps>
Mon 09 Oct 2017 08:36:43 PM UTC, comment #10: 

@Sebastian,

I still encounter the address sanitizer error and crash (seg-fault). I don't see where I've enabled that setting. Has Apple made that a default that In need to disable?

Or maybe Fink has it turned on for one of the dependencies?


Ben Abbott <bpabbott>
Group Member
Mon 09 Oct 2017 06:16:52 PM UTC, comment #9: 

@Ben: it seems that I need the includes defined in JAVA_CPPFLAGS (-I/System/Library/Framework/...). Then Java 9 works for me. See patch below.

(file #42102)

Sebastian <sschoeps>
Mon 09 Oct 2017 04:17:20 PM UTC, comment #8: 

Absolutely, works here with Java 8 perfectly. There are some small Java library differences causing some test failures with Java 9, but works other than that.

AFAICT bug #52061 only happens when AddressSanitizer is enabled. Without it everything is fine (at least doesn't crash).

Mike Miller <mtmiller>
Group Member
Mon 09 Oct 2017 03:10:00 PM UTC, comment #7: 

Mike

I can't tell from bug #52061, does Java work on any version of Linux using Java 8 or 9?

Since Java 8, it looks to me as if using JDK for macOS is similar to linux. If you or someone else can confirm Java 8 or 9 works and what options you've used, I expect I can get the same to work on macOS.

Ben Abbott <bpabbott>
Group Member
Sun 08 Oct 2017 11:22:13 PM UTC, comment #6: 

I'm happy to review and apply the revised patch once someone is able to demonstrate that Java can work.

Mike Miller <mtmiller>
Group Member
Sun 08 Oct 2017 07:20:14 PM UTC, comment #5: 

The seg-fault I'm seeing may have the same underlying cause as the same/similar problem seen on Linux

https://savannah.gnu.org/bugs/?52061

Ben Abbott <bpabbott>
Group Member
Sun 08 Oct 2017 07:18:12 PM UTC, comment #4: 

I'm attaching an updated patch with context, that works for me for Java 9 on macOS 10.13 (High Sierra). By "works for me", I mean Octave builds. Unfortunately, a seg-fault occurs if Java is used by Octave.

In any event, if someone can verify this patch works for Sierra and Java 8, then perhaps it should be pushed.



(file #42096)

Ben Abbott <bpabbott>
Group Member
Sun 20 Aug 2017 06:12:46 PM UTC, comment #3: 

ok, version 2 of the patch does change "scripts/java/module.mk" anymore.

(file #41593)

Sebastian <sschoeps>
Sun 20 Aug 2017 05:29:08 PM UTC, comment #2: 

See bug #51803 for dropping support for Java 1.3.

Mike Miller <mtmiller>
Group Member
Sun 20 Aug 2017 04:48:12 PM UTC, comment #1: 

I can confirm that Java 9 no longer allows building with -source 1.3 -target 1.3. I think that should be fixed separately, this is not a macOS issue.

Mike Miller <mtmiller>
Group Member
Sun 20 Aug 2017 11:54:33 AM UTC, original submission:  

jwe proposed to unify Java handling in https://lists.gnu.org/archive/html/octave-maintainers/2016-05/msg00151.html. The attached patch (for devel) works and gets rid of an unintended Java 1.6 requirement caused by including "-framework JavaVM". Additionall, "-source 1.3 -target 1.3" in "scripts/java/module.mk" is dropped as it will not work with Java 1.9 anymore (minimum is 1.6).

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #42899:  changeset.patch added by bpabbott (3KiB - application/octet-stream)
file #42887:  screenshot.png added by sschoeps (49KiB - image/png - dialog asking for Java SE6 (sorry in German))
file #42883:  octave_devel_mac_java8.patch added by bpabbott (3KiB - application/octet-stream)
file #42139:  octave_devel_mac_java6.patch added by bpabbott (3KiB - application/octet-stream)
file #42108:  configure.txt added by sschoeps (8KiB - text/plain)
file #42102:  octave_devel_mac_java5.patch added by sschoeps (2KiB - application/octet-stream)
file #42096:  octave_devel_mac_java4.patch added by bpabbott (2KiB - application/octet-stream)
file #41593:  octave_devel_mac_java2.patch added by sschoeps (2KiB - application/octet-stream)
file #41586:  octave_devel_mac_java.patch added by None (2KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jpswensen (Posted a comment)
  • -email is unavailable- added by bpabbott (Updated the item)
  • -email is unavailable- added by sschoeps (Updated the item)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 16 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-26 mtmiller Carbon-CopyRemoved 80942 -
    2018-02-01 bpabbott Attached File- Added Screen Shot 2018-02-01 at 7.10.11 AM.png, #43151
    2018-01-17 bpabbott StatusReady For Test Done
        Open/ClosedOpen Closed
    2018-01-14 bpabbott StatusIn Progress Ready For Test
    2018-01-13 bpabbott StatusNone In Progress
        Assigned toNone bpabbott
    2018-01-13 bpabbott Attached File- Added changeset.patch, #42899
    2018-01-11 sschoeps Attached File- Added screenshot.png, #42887
    2018-01-10 bpabbott Attached File- Added octave_devel_mac_java8.patch, #42883
    2017-10-13 bpabbott Attached File- Added octave_devel_mac_java6.patch, #42139
    2017-10-10 sschoeps Attached File- Added configure.txt, #42108
    2017-10-09 sschoeps Attached File- Added octave_devel_mac_java5.patch, #42102
    2017-10-08 bpabbott Attached File- Added octave_devel_mac_java4.patch, #42096
    2017-08-20 sschoeps Attached File- Added octave_devel_mac_java2.patch, #41593
    2017-08-20 None Attached File- Added octave_devel_mac_java.patch, #41586

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code