bugGNU Octave - Bugs: bug #42993, Octave's Java does not load...


bug #42993: Octave's Java does not load Service-Provider-Interface classes

Submitter:  None
Submitted:  Fri 15 Aug 2014 12:28:35 AM UTC
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Postponed Assigned to:  None
Originator Name:  Chris Carroll Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Fri 15 Aug 2014 04:33:18 PM UTC, comment #1: 

Octave's Java implementation does have a few wrinkles, yes; some are mentioned here in the task tracker:
I doubt if they will be solved in the near future as no one is working on them at present.

If it may comfort you:
While building the UNO Java spreadsheet interface to LibreOffice, I had to jump through a few hoops to get stuff together. Maybe you can get a first impression of some required workarounds if you compare this (a formal Java implementation):

...with this (how it ended up in Octave (-Forge)):

(esp. the queryInterface and PropertyValue stuff gave headaches)

Now these examples don't quite directly apply to your problem; but I think they do show that workarounds can be found in unexpected places and -directions.

Philip Nienhuis <philipnienhuis>
Group Member
Fri 15 Aug 2014 12:28:35 AM UTC, original submission:  

Some Java libraries specify interface implementations through the Service Provider Interface (http://docs.oracle.com/javase/tutorial/sound/SPI-intro.html), but Octave does not seem to load the implementations. This may be a problem with Octave's custom ClassLoader implementation.

Sample code that produces the problem:


public class LoadResource {
        public LoadResource() {
                System.out.println("Getters say:");
                Iterator<Getter> iterator = ServiceRegistry.lookupProviders(Getter.class);
                while (iterator.hasNext()) {
                        System.out.println("  Getter says: " + iterator.next().get());
        public static void main( String[] args ) {
                new LoadResource();


public interface Getter {
        public String get();


public class DefaultGetter implements Getter {
        public String get() {
                return "GOT IT!";



After creating a jar from these files, the expected result is shown when the jar is run outside of Octave:

Getters say:
  Getter says: GOT IT!

In Octave, the result is:

>> javaaddpath('octaveProblem-0.0.1-SNAPSHOT.jar')
>> javaObject('octaveProblem.LoadResource');
Getters say:



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

Attach Files:

Attached Files
file #31902:  octaveProblem-0.0.1-SNAPSHOT.jar added by None (4KiB - 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 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 group members can vote.


    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-04-27 mtmiller Carbon-CopyRemoved 80942 -
    2018-04-27 mtmiller Item GroupNone Incorrect Result
        StatusNone Postponed
        Release3.8.1 dev
    2015-02-22 mtmiller CategoryNone Libraries
    2014-08-15 None Attached File- Added octaveProblem-0.0.1-SNAPSHOT.jar, #31902

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code