octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #42993] Octave's Java does not load Service-Pr


From: anonymous
Subject: [Octave-bug-tracker] [bug #42993] Octave's Java does not load Service-Provider-Interface classes
Date: Fri, 15 Aug 2014 00:28:36 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36

URL:
  <http://savannah.gnu.org/bugs/?42993>

                 Summary: Octave's Java does not load
Service-Provider-Interface classes
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Fri 15 Aug 2014 12:28:35 AM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
             Assigned to: None
         Originator Name: Chris Carroll
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.8.1
        Operating System: GNU/Linux

    _______________________________________________________

Details:

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:

octaveProblem.LoadResources.java:

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());
                }
                System.out.println("Done!");
        }
        public static void main( String[] args ) {
                new LoadResource();
        }
}


octaveProblem.Getter.java:

public interface Getter {
        public String get();
}


octaveProblem.DefaultGetter.java:

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


META-INF/services/octaveProblem.Getter:

octaveProblem.DefaultGetter


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!
Done!


In Octave, the result is:

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




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Fri 15 Aug 2014 12:28:35 AM UTC  Name: octaveProblem-0.0.1-SNAPSHOT.jar 
Size: 4kB   By: None

<http://savannah.gnu.org/bugs/download.php?file_id=31902>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?42993>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]