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

 
 

bug #48813: Java interface: untyped []

Submitted by:  Ernst Reissner <ernstreissner>
Submitted on:  Thu 18 Aug 2016 11:34:25 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: Wont FixAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission 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>
Project 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>
Project Administrator
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>
Project Administrator
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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by siko1056 (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by ernstreissner (Submitted the item)
  • -unavailable- added by ernstreissner
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 18 Aug 2016 05:40:18 PM UTCmtmillerStatusNone=>Wont Fix
      Open/ClosedOpen=>Closed
    Thu 18 Aug 2016 11:34:25 AM UTCernstreissnerCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1