bugGNU Octave - Bugs: bug #62930, error comparing octave_java objects

 
 

bug #62930: error comparing octave_java objects

Submitter:  Ernst Reissner <ernstreissner>
Submitted:  Sun 21 Aug 2022 09:11:09 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  reissner Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 26 Aug 2022 09:49:30 PM UTC, comment #5: 

I checked in the change on the development branch here http://hg.savannah.gnu.org/hgweb/octave/rev/434b5a1b9498.

I will open a new bug report for the equality operator '==' and Java objects.

Rik <rik5>
Group administrator
Wed 24 Aug 2022 10:22:06 PM UTC, comment #4: 

(Maybe for another bug report) It seems that matlab supports the "==" operator for java objects. Would that be doable in Octave?

Pantxo Diribarne <pantxo>
Group Member
Wed 24 Aug 2022 10:18:23 PM UTC, comment #3: 

I tested the patch with the original test case and that returns true as expected, as it does for float and double types, but it returns false for mixed numeric classes while with native octave types it would return true:


f1  = javaObject ("java.lang.Float",1.0);
d2  = javaObject ("java.lang.Double",1.0);
isequal (f1, d2)
## -> 0
isequal (single (1.0), double (1.0))
## -> 1


The good news is that Matlab online seems to behave the same.

I also tested with other xml related java objects and they all seem to feature the "equals" method :


javaaddpath ("/usr/share/java/xml-apis.jar");
javaaddpath ("/usr/share/java/xercesImpl.jar");
doc = javaObject ("org.apache.xerces.dom.DocumentImpl");
root = doc.createElement ("RootNode");
isequal (doc, doc)
## -> 1
isequal (root, root)
## -> 1
root2 = root;
isequal (root, root2)
## -> 1
isequal (doc, root)
## -> 0


So this looks robust enough and I think the patch can be pushed.

Pantxo Diribarne <pantxo>
Group Member
Tue 23 Aug 2022 08:21:50 PM UTC, comment #2: 

I'm attaching a patch that implements what Pantxo proposed in comment #1.  Marking as "Patch Submitted".

(file #53601)

Rik <rik5>
Group administrator
Tue 23 Aug 2022 12:58:23 PM UTC, comment #1: 

For the case at hand a workaround is to use the `equals` methods of java integer objects:


i1  = javaObject ("java.lang.Integer",1.0);
i2  = javaObject ("java.lang.Integer",2.0);
i1.equals (i2)


Maybe this could be used as a generic method to compare octave_java objects in isequal.m?

Pantxo Diribarne <pantxo>
Group Member
Sun 21 Aug 2022 09:11:09 AM UTC, original submission:  

octave:24> Integer  = javaObject("java.lang.Integer",1.0);
octave:25> isequal(Integer ,Integer)
error: isequal: Impossible to reach code.  File a bug report.
error: called from
    isequal at line 175 column 9

Ernst Reissner <ernstreissner>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #53601:  bug62930.cset added by rik5 (1001B - 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 rik5 (Updated the item)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by ernstreissner (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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-26 rik5 StatusPatch Reviewed Fixed
        Open/ClosedOpen Closed
        Release7.2.0 dev
    2022-08-24 pantxo StatusPatch Submitted Patch Reviewed
    2022-08-23 rik5 Attached File- Added bug62930.cset, #53601
        Item GroupNone Unexpected Error or Warning
        StatusConfirmed Patch Submitted
    2022-08-23 pantxo CategoryInterpreter Octave Function
        StatusNone Confirmed
        Release7.1.0 7.2.0

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code