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

 
 

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

Submitted by:  Andrew Janke <apjanke>
Submitted on:  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

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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.

{verbatim}

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

error: [java] java.lang.ClassNotFoundException: org.slf4j.Logger
{verbatim}

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.

{verbatim}
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
{verbatim}

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:
   
   
Comment:
   

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)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.6