bugGNU Octave - Bugs: bug #50358, Document that no null java object...

 
 

bug #50358: Document that no null java object exists

Submitter:  Ernst Reissner <ernstreissner>
Submitted:  Mon 20 Feb 2017 09:54:13 AM UTC
   
 
Category:  Documentation Severity:  2 - Minor
Priority:  3 - Low Item Group:  Documentation
Status:  None Assigned to:  None
Originator Name:  Ernst Reissner Open/Closed:  * Open
Release:  * 4.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 20 Feb 2017 06:45:09 PM UTC, comment #4: 

As Carnë said, for Matlab compatibility, any Java null reference must be converted to an empty array and it must be of type double. This has been worked out before, but can be tested again in a current version of Matlab if confirmation is needed.

The Matlab compatible way to test for a "null" return value from a Java method is to test that both isempty(x) and isnumeric(x) are true (see http://www.mathworks.com/matlabcentral/newsreader/view_thread/53512 for example).

Mike Miller <mtmiller>
Group Member
Mon 20 Feb 2017 05:00:53 PM UTC, comment #3: 

I just wonder, whether it is possible to represent null as [] of octave_java type.
If not, then it is clear, that isjava([]) returns false.
But yes, i feel, this is worth mentioning.

Ernst Reissner <ernstreissner>
Mon 20 Feb 2017 03:41:36 PM UTC, comment #2: 


> I do not feel comfortable with representing null as double-valued [].
> [...]
> I think one should clarify, that this returns false for null values.


There is no null values.  They get automatically converted to an empty double array of size [0, 0].  This is required for Matlab compatibility (at least in 2010b).

Maybe a note on isjava remembering people that there is no null instead?

Carnë Draug <carandraug>
Group Member
Mon 20 Feb 2017 10:17:58 AM UTC, comment #1: 

I do not feel comfortable with representing null as double-valued [].

The result is that the null value of a java class ,
e.g. java.math.Rounding mode is a double,
so changing the type.

b=javaArray("java.math.BigDecimal",3)
yields
b =
<Java object: java.math.BigDecimal[]>

and

b(3)=javaObject("java.math.BigDecimal",3.0)
yields

b =
<Java object: java.math.BigDecimal[]>

b(2)

yields
ans = [](0x0)
representing null.

On the other hand,
class(b(3)) yields ans = java.math.BigDecimal
whereas
class(b(2)) yields double
although in an array java.math.BigDecimal[]



Ernst Reissner <ernstreissner>
Mon 20 Feb 2017 09:54:13 AM UTC, original submission:  

According to documentation, A.4
isjava (x) Return true if x is a Java object.
I think one should clarify, that this returns false for null values.

Ernst Reissner <ernstreissner>

 

(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 mtmiller (Posted a comment)
  • -email is unavailable- added by ernstreissner (Submitted the item)
  • -email is unavailable- added by ernstreissner
  •  

    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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-02-20 mtmiller Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
    2017-02-20 mtmiller CategoryNone Documentation
    2017-02-20 rik5 Carbon-CopyRemoved 72865 -
    2017-02-20 rik5 Summaryisjava(null) is false Document that no null java object exists
    2017-02-20 carandraug Item GroupNone Documentation
    2017-02-20 ernstreissner Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-4b4b.
    Corresponding source code