This is just to keep a record for future work.
Using the terminal
open ontology.owl
Or double clicking on a file in Finder used to work with Protege 5.5.0, but now does not. Here is a summary of @gouttegd analysis about the issue, leaving out some of the ranting :P
@gouttegd says:
Since approximately the times of Brian Kernighan and Dennis Ritchie, the standard way of passing arguments (say, filenames) to a program was to pass them as arguments to the main function of said program. That is, if you call myprog myfile, the main function of myprog would be called with an array containing myfile (along with the name under which the program was called, but that’s irrelevant).
That standard approach has since then been used by all operating systems (even Windows!) and almost all languages.
But of course, that is too standard for Apple. [...censored rant...]
.
So, on macOS, when you call open ecto-edit.owl, [...censored..]
finds an appropriate application for .owl file, and then does not call that application with ecto-edit.owl as an argument! Instead, it calls the application with an empty command line, and then sends the application an Apple-specific event that the application is supposed to react to (by using the Apple-specific Cocoa API).
Now, Protégé contains some code specifically intended to deal with this kind of Apple [..censored..]
, but this is one of the area that has required some changes with the migration to Java11, and apparently the new code is not working…
Bottom line: this is not, contrary to what I thought, a problem with the new launcher. This is a Java11/macOS problem.
Nico: Maybe I can somehow write my own launcher and stick it into bash profile or zshrc
Damien: if you want your own launcher, you can make something like that:
#!/bin/sh
/Applications/Protégé-560-beta.app/Contents/run.sh "$PWD/$1"
That is, bypass Apple’s open completely.
(Nico has confirmed, this works, but opens Protege in the foreground rather than detached mode, which is great for him (better access to logs) but may not be ideal for normal users.)
@gouttegd says:
Damien: To be clear: ranting aside, and while the problem would not exist if not for Apple’s idiosyncrasies, this is still a bug in Protégé. The fact that you could open file.owl with Protégé 5.5.0 means that Protégé 5.5.0 reacted correctly to Apple desktop events; the fact that Protégé 5.6.0 does not is undoubtedly a regression.
Well, that’s very unlikely to be fixed anytime soon. As far as I understand, Protégé is doing The Right Thing by using the standard java.awt.Desktop API, instead of the (non-standard, deprecated, and simply not usable on Java >= 9) com.apple.eawt.Application class that we used before.
Except that the setFileOpenHandler of that API simply does not seem to work.
I tried building a very minimal Java application that basically does nothing except setting this handler, following exactly the API’s documentation… and the application never receives any “open file” event! The event handler is never called.
On the net people seem to have complained about various problems with that API for several years…
So, I give up. I am now convinced that whatever the problem is, it is not in Protégé’s code. It’s either another Apple idiosyncrasy or a bug in the JRE, or maybe even both.
For the record: It seems that a possible solution would be to start, at the same time as the Protégé application itself, another program in parallel, that would run in the background for as long as Protégé is running. That helper daemon would solely be tasked with listening to Apple events (and so would have to be written in something else than Java, since apparently we can’t get those events from a Java program; most likely it would have to be written in ObjC or in Swift), and upon receiving a “open file” event it would have to somehow communicate that to the main Protégé process.
If anyone is willing to test that “solution”, be my guest. As for me, no way I am ever going to even consider that even further.