bugGNU Octave - Bugs: bug #48813, Java interface: untyped []

 
 

bug #48813: Java interface: untyped []

Submitter:  Ernst Reissner <ernstreissner>
Submitted:  Thu 18 Aug 2016 11:34:25 AM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Wont Fix Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 23 Aug 2016 08:12:42 AM UTC, comment #6: 

Yes, I agree, Matlab compatibility goes first.
Maybe one shall trigger the mathworks people to do something...

Ernst Reissner <ernstreissner>
Tue 23 Aug 2016 06:25:12 AM UTC, comment #5: 

The behaviors of comment #1 and comment #4 are due to Matlab compatibility. Maybe its not the best, but otherwise we break compatibility. I also vote for Wont Fix.

Kai Torben Ohlhus <siko1056>
Group Member
Thu 18 Aug 2016 10:25:13 PM UTC, comment #4: 

Hi Mike,
ok, but there are there empty matrices of various types, right?
I suspect, if one generic null value is not feasable,
it would be better to have a null value of appropriate type.

I tried:
=verbatim+
octave:23> class(char([]))
ans = char
octave:24> class(single([]))
ans = single
octave:25> class(logical([]))
ans = logical
-verbatim-

Ernst Reissner <ernstreissner>
Thu 18 Aug 2016 07:40:20 PM UTC, comment #3: 

No, I don't think this is possible without breaking many things. An empty array is still a numeric array, and the default type is double, therefore the default empty (or null) type is a double array of size 0×0.

Mike Miller <mtmiller>
Group Member
Thu 18 Aug 2016 06:31:41 PM UTC, comment #2: 

I agree on all you say.
My problem is only, that class([]) is double.
This does not fit Java, for which null refers to an arbitrary untyped reference type.
Java's double type corresponds with Octave's double type,
but this is not a reference type in Java at all.
Thus class([])==double does not fit at all.

If possible, I would prefer an untyped version of the empty array.
Is this forseen in Octave??
maybe some class 'unknown'?

Ernst Reissner <ernstreissner>
Thu 18 Aug 2016 05:40:18 PM UTC, comment #1: 

If Matlab says that a Java null object is converted into a Matlab empty matrix, then it's working as expected.

According to my reading this is correct. A null value returned from Java should become an Octave empty (double) matrix. Any empty numeric matrix passed in to Java should be treated as a null reference.

The typical Octave equivalent to "x == null" is "isempty (x)". This is an extremely common usage, so it makes sense that a Java null would be returned as an empty array.

If you create a "static boolean isNull (Object obj)" function, and pass it various empty (numeric) matrices, they should all return true.

Nothing needs to be fixed here.

Mike Miller <mtmiller>
Group Member
Thu 18 Aug 2016 11:34:25 AM UTC, original submission:  

This may be a bug or not:
Matlab's java interface represents null on Java side
as [] on Matlab side.

In octave typeinfo([]) is null_matrix
but class([]) is double.

This does not fit that for non-null Java references
typeinfo(x) is octave_java
and class(x) returns the Java classname,

because null has no class in Java:
null.getClass() thows NullpointerException
and null is used in all reference classes.
Null can be casted to all we want.

Is there some solution to that? how does Matlab behave here????

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 siko1056 (Posted a comment)
  • -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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-08-18 mtmiller StatusNone Wont Fix
        Open/ClosedOpen Closed
    2016-08-18 ernstreissner Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code