bugGNU Octave - Bugs: bug #58119, isa() does not respect interfaces...


bug #58119: isa() does not respect interfaces inherited from superclasses for Java objects

Submitter:  Andrew Janke <apjanke>
Submitted:  Sun 05 Apr 2020 05:01:31 PM UTC
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 5.2.0 Operating System:  * Mac OS
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Sun 05 Apr 2020 05:05:24 PM UTC, comment #1: 

Also, I'm trying to work around this by using Java reflection, but I can't seem to get the Class instance for org.slf4j.Logger.


>> wantKlass = javaMethod('forName', 'java.lang.Class', 'org.slf4j.Logger')

error: [java] java.lang.ClassNotFoundException: org.slf4j.Logger

Is this because Octave is using a special ClassLoader for the classes on the dynamic Java classpath? Is there a way of doing java.lang.Class.forName() for them?

Andrew Janke <apjanke>
Sun 05 Apr 2020 05:01:31 PM UTC, original submission:  

It seems that isa(), when called on a Java object, doesn't properly respect interface inheritance from superclasses.

I have a method written against the org.slf4j.Logger interface. It should accept instances of any class that implements that interface, either directly or through inheritance. In some of my code, my method is receiving org.slf4j.impl.Log4jLoggerAdapter objects and storing them in a variable named jLogger. This class is an indirect subclass of org.slf4j.helpers.NamedLoggerBase, which implements org.slf4j.Logger. However, isa(jLogger, 'org.slf4j.Logger') returns false.

debug> jLogger
jLogger =
<Java object: org.slf4j.impl.Log4jLoggerAdapter>

debug> klass = jLogger.getClass;
debug> klass.getName
ans = org.slf4j.impl.Log4jLoggerAdapter
debug> superklass1 = klass.getSuperclass;
debug > superklass1.getName
ans = org.slf4j.helpers.MarkerIgnoringBase
debug> superklass2 = superklass1.getSuperclass;
debug> superklass2.getName
ans = org.slf4j.helpers.NamedLoggerBase
debug> ifcs2 = superklass2.getInterfaces;
debug> ifcs2(1).getName
ans = org.slf4j.Logger
debug> isa(jLogger, 'org.slf4j.Logger')
ans = 0

Affects Octave 4.4.1 and 5.2.0. This is on macOS, but I'd suspect it affects all OSes.

Andrew Janke <apjanke>


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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by apjanke (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.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code