bugGNU Octave - Bugs: bug #53305, usejava ("awt") may fail...

 
 

bug #53305: usejava ("awt") may fail on macOS

Submitter:  Sebastian <sschoeps>
Submitted:  Thu 08 Mar 2018 03:28:24 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Wont Fix Assigned to:  None
Originator Name:  Sebastian Schöps Open/Closed:  * Closed
Release:  * dev Operating System:  * Mac OS
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 11 Jul 2018 03:58:44 PM UTC, comment #12: 

Closing this report since the result is "Won't Fix".  Some time in the distant future, say 2 years from now, jwe's temporary fix in comment #4 should be reversed.

Rik <rik5>
Group administrator
Sat 07 Jul 2018 11:16:36 AM UTC, comment #11: 


> How long will it take for u171 to diffuse into user's installations? It was released in April, but I also suspect they have pushy background update software that works hard to make you update to the latest JDK.


That's a really good question.

I don't recall seeing any nag screens on my Mac machines, many of which were not updated to u171 until I was working on this issue, so I think there actually isn't a background updater/notifier for JDK on Mac, even though that's how Oracle normally operates. I also have a VM that is running just JDK 1.7, and I haven't seen any update nag screens there either.

So I can only guess at how many users are still running older versions of the JDK, but my guess would be: a lot. Because how would they know they're supposed to upgrade?

Sebastian and I are working on an "Oracle.app" distribution of Oracle for Mac, with an accompanying https://octave-app.org/ website. We could put up a page there for "what to do with Octave if you get an 'Install Java 6' dialog" and I think it could get decent Googlejuice, but users would have to know what to search for in the first place, instead of writing it off as an inscrutable app crash with a weird dialog.

This also depends on whether GNU Octave wants to support Java 1.7 on Mac. The last (ever) available JDK 1.7 still has the bug. Per Oracle's system requirements at https://java.com/en/download/help/sysreq.xml, JDK 8 is supported all the way back to OS X 10.8, which is pretty old in Mac terms, so I don't think it would be unreasonable to just support Java 1.8+ on Mac.

Andrew Janke <apjanke>
Tue 03 Jul 2018 03:32:55 PM UTC, comment #10: 

I'm fine treating this as an upstream bug in the Oracle JDK / MacOS.  How long will it take for u171 to diffuse into user's installations?  It was released in April, but I also suspect they have pushy background update software that works hard to make you update to the latest JDK.

The reason to hypothesize about a date is that jwe made a temporary change in comment #4 that should probably be reversed in the future.

Rik <rik5>
Group administrator
Tue 03 Jul 2018 07:24:19 AM UTC, comment #9: 

Even though 1.8u172 is out, you might not want to use that one as the standard installation. Oracle releases two JDK releases at the same time: a Critical Patch Update ("CPU") and Patch Set Update ("PSU"). It's not  documented on the download page, but I think u171 is the CPU and u172 is the PSU. Oracle recommends that most users stick with the CPU. The PSU is sort of like a beta release for the next CPU.

http://www.oracle.com/technetwork/java/javase/cpu-psu-explained-2331472.html

Andrew Janke <apjanke>
Tue 03 Jul 2018 05:51:35 AM UTC, comment #8: 

I suggest that we close this bug and ignore the problem. Users will hopefully upgrade their Java anyway soon due to security concerns.

Sebastian <sschoeps>
Tue 03 Jul 2018 03:11:04 AM UTC, comment #7: 
Ben Abbott <bpabbott>
Group Member
Sun 01 Jul 2018 01:18:52 AM UTC, comment #6: 


> It is not clear whether this dialog box is a macOS or Octave issue.


This "No Java runtime present, requesting install" dialog box that pops up, at least when using a Java 1.8 JDK, is a bug in older builds of Oracle's JDK 1.8. Newer builds (like u171) don't have this issue.

Could just ask users to install a newer update of the JDK.

I can confirm that I used to get this dialog, and it went away for me when I upgraded my JDK 1.8 to u171.

If you really want to work around it for older JDK 1.8 builds, you can dynamically load `libjli.dylib`, which seems to suppress use of the Apple Java 1.6 loader stub that produces this message.

Reference: https://github.com/s-u/rJava/issues/37

Andrew Janke <apjanke>
Fri 09 Mar 2018 03:35:27 PM UTC, comment #5: 


>Do the other options (swing, jvm) provoke similar problems?
>as awt is just the first in the switch series.


No, it's only awt. Checking for Swing is fine


octave:1> methods ("javax.swing.Popup")
Methods for class javax.swing.Popup:
void show()
void hide()
void wait(long, int) throws java.lang.InterruptedException
void wait() throws java.lang.InterruptedException
void wait(long) throws java.lang.InterruptedException
boolean equals(java.lang.Object)
java.lang.String toString()
int hashCode()
java.lang.Class getClass()
void notify()
void notifyAll()


but AWT asks to install the old Java 1.6.

Sebastian <sschoeps>
Fri 09 Mar 2018 02:39:16 PM UTC, comment #4: 

I tried the change suggested in comment #3 and I still see


octave:1> methods ("java.awt.Frame");
No Java runtime present, requesting install.
2018-03-09 15:32:01.865 octave-cli[72558:10349204] JLRequestRuntimeInstall: Error calling: CFMessagePortCreateRemote


even though the JVM is loaded and working:


octave:1> javaMethod ("getProperty", "java.lang.System", "java.version")
ans = 9.0.4


It's only the last test in ov-java.cc that fails when it tries to  execute usejava ("awt").  So for now, I've pushed this change:

http://hg.savannah.gnu.org/hgweb/octave/rev/1e207bd05b5d

Though this doesn't fix the real problem, it should allow the tests to run.

I hesitate to install a change to usejava.m that would warn about this problem on OS X systems specifically for AWT since I don't know whether there may be other parts of the java system that will fail similarly.  It seems best to find a way to fix the real problem and prevent the JVM from aborting the program when a component doesn't work.

John W. Eaton <jwe>
Group administrator
Thu 08 Mar 2018 11:44:08 PM UTC, comment #3: 

One more thing to test on macOS might be to change scripts/java/module.mk


diff --git a/scripts/java/module.mk b/scripts/java/module.mk
--- a/scripts/java/module.mk
+++ b/scripts/java/module.mk
@@ -37,7 +37,7 @@ JAVA_CLASSES = $(JAVA_SRC:.java=.class)
 $(%canon_reldir%_JAVA_CLASSES) : %.class : %.java | %reldir%/$(octave_dirstamp)
        $(AM_V_GEN)$(MKDIR_P) %reldir%/$(org_octave_dir) && \
        ( cd $(srcdir)/scripts/java; \
-         "$(JAVAC)" -source 1.6 -target 1.6 -Xlint:-options \
+         "$(JAVAC)" -source 9 -target 9 -Xlint:-options \
                     -d $(abs_top_builddir)/scripts/java \
                     $(org_octave_dir)/$(<F) )


or just drop the -source and -target options entirely, to see if the bytecode compilation version has anything to do with this bug. Is it because the bytecode is compiled for Java 6 that the system is specifically trying to have Apple Java 6 installed?

Mike Miller <mtmiller>
Group Member
Thu 08 Mar 2018 06:54:34 PM UTC, comment #2: 

The easiest but maybe kludgy fix is to enclose the contents of that case clause in an "if (! ismac) ... " block.

Do the other options (swing, jvm) provoke similar problems? as awt is just the first in the switch series.

Philip Nienhuis <philipnienhuis>
Group Member
Thu 08 Mar 2018 04:29:06 PM UTC, comment #1: 

The actual code that Octave executes is in usejava.m


    case "awt"
      try
        dum = methods ("java.awt.Frame");
        retval = ! javaMethod ("isHeadless", "java.awt.GraphicsEnvironment");
      end_try_catch


@Sebastian: Just to help narrow it down, can you log in to the macOS buildbot, start octave interactively, and then try each command individually to see which one is causing the dialog box?

The next question to google or search on StackOverflow for is how to correctly detect the features of a JVM.  If this isn't the right way, fine, we can change it.  But I don't know why it appears to work on other platforms, except possibly that they never have Apple's version of Java and always have a true version from Sun/Oracle.

Rik <rik5>
Group administrator
Thu 08 Mar 2018 03:28:24 PM UTC, original submission:  

Calling usejava ("awt") triggers a GUI dialog box to install the outdated Apple Java 1.6


To open "application" you need to install the legacy Java SE 6 runtime.


It is not clear whether this dialog box is a macOS or Octave issue. Java was previously supplied by Apple (version <=1.6) and now it comes from Sun (>1.6). Sun's Java is treated on macOS like on Unix, while Apple's Java needed a special treatment for linking "-framework...".

I have compiled java code on macOS that contains awt without issues (example attached), so it seems not actually necessary to get the Java SE 6.

This issue was initially discussed at https://savannah.gnu.org/bugs/?53151.

Sebastian <sschoeps>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #43491:  test_AWT.java added by sschoeps (169B - application/octet-stream - simple JAVA source file to test AWT)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by apjanke (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by sschoeps (Submitted the item)
  • -email is unavailable- added by sschoeps
  • -email is unavailable- added by sschoeps
  • -email is unavailable- added by sschoeps
  •  

    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 group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-07-11 rik5 Open/ClosedOpen Closed
    2018-07-03 rik5 StatusNone Wont Fix
    2018-03-08 sschoeps Attached File- Added test_AWT.java, #43491
        Carbon-Copy- Added -email is unavailable-
        Carbon-Copy- Added -email is unavailable-
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code