bugGNU Octave - Bugs: bug #44764, exist() does not recognize Java...

 
 

bug #44764: exist() does not recognize Java objects

Submitter:  Thomas Foesel <thofoe>
Submitted:  Tue 07 Apr 2015 03:56:48 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 08 Apr 2015 04:22:57 PM UTC, comment #7: 

We only need to override the base object's functions that we are interested in.  The default is to return false, so we're good.


ov-base.h:  virtual bool is_object (void) const { return false; }


Rik <rik5>
Group administrator
Wed 08 Apr 2015 03:54:56 PM UTC, comment #6: 

Yes, but only this weekend this I started playing more with stuff in libinterp/java-octave and didn't want to touch this.

Should we keep octave_java::is_object and just have it return false?

Carnë Draug <carandraug>
Group Member
Wed 08 Apr 2015 03:20:25 PM UTC, comment #5: 

Okay, I'm not surprised.  Did you see my comment in the cset?


+  // FIXME: Is a variable containing a java object an object?
+  //        Or should this be is_constant like a matrix?
+  bool is_object (void) const { return true; }


I changed to using is_constant instead and 'make check' passes for me.  See new cset (http://hg.savannah.gnu.org/hgweb/octave/rev/d7b1999f0554).


Rik <rik5>
Group administrator
Wed 08 Apr 2015 12:27:56 PM UTC, comment #4: 

The fix is causing other bugs, because while exist() must recognize java objects, isobject() must not recognize java objects.  On Matlab r2010b:


>> a = javaObject ('java.lang.Double', 10)

a =

10.0

>> isobject(a)

ans =

     0


This is causing fieldnames to fail its tests (because it uses isobject() to distinguish them).

Carnë Draug <carandraug>
Group Member
Wed 08 Apr 2015 05:07:25 AM UTC, comment #3: 

Fixed in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/302e48c2de5d).  Closing report.

Rik <rik5>
Group administrator
Tue 07 Apr 2015 07:12:41 PM UTC, comment #2: 

See task #12601 at the bottom of the original report (https://savannah.gnu.org/task/?12601)

Philip Nienhuis <philipnienhuis>
Group Member
Tue 07 Apr 2015 04:43:53 PM UTC, comment #1: 

Confirmed.  This should return '1' because j_str obviously exists as a variable within the workspace which you can check with 'who' or 'whos'.


octave:1> j_str=javaObject('java.lang.String','Hello, world.');
octave:2> exist('j_str')
ans = 0
octave:3> who
Variables in the current scope:

ans    j_str

octave:4> whos
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        ans         1x1                          8  double
        j_str       1x1                          0  java.lang.String

Total is 2 elements using 8 bytes


Rik <rik5>
Group administrator
Tue 07 Apr 2015 03:56:48 PM UTC, original submission:  

The Octave built-in function exist() does not recognize Java objects: the following code

===========================
j_str=javaObject('java.lang.String','Hello, world.');
exist('j_str')
===========================

gives the output value 0, i.e. false. This is counter-intuitive/wrong, and also different to Matlab (check with my latest available version, R2012b) which returns 1, i.e. true; so I guess this is a bug.

This behavior is also the case if the variable has been created previously. Octave returns the value 0 also for the following:

===========================
j_str=42;
j_str=javaObject('java.lang.String','Hello, world.');
exist('j_str')
===========================

Thomas Foesel <thofoe>

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by thofoe (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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-04-08 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-04-08 carandraug StatusFixed Confirmed
        Open/ClosedClosed Open
    2015-04-08 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-04-07 rik5 Item GroupNone Incorrect Result
        StatusNone Confirmed
        Release3.8.2 dev

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code