bugGNU Octave - Bugs: bug #42701, java toString method returns char...


bug #42701: java toString method returns char instead of java.lang.String

Submitted by:  Carnë Draug <carandraug>
Submitted on:  Mon 07 Jul 2014 09:49:25 PM UTC  
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

Add a New Comment(Rich Markup)

You are not logged in

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


Thu 15 Dec 2016 06:06:42 PM UTC, comment #4:

Octave 4.2.0 still behaves the same (as reported for Octave 3.8.1) in this respect.

Hartmut <hardy>
Thu 10 Jul 2014 11:56:18 AM UTC, comment #3:

I just asked on IRC, and on Matlab R2014a happens the same:

Carnë Draug <carandraug>
Project Member
Thu 10 Jul 2014 11:13:02 AM UTC, comment #2:

I tested with Matlab R2010b. Yes, the documentation does suggest that but then, the following documentation on the same page:

> With the MATLAB char function, you can convert java.lang.String
> objects and arrays to MATLAB character arrays.

does not make a lot of sense. Why are they writing about calling char() on a java.lang.String if that an object cannot exist (it is automatically converted to char)?

This is very much against their documentation. I just tried your second example:

Carnë Draug <carandraug>
Project Member
Thu 10 Jul 2014 01:18:58 AM UTC, comment #1:

Hmm, this seems to directly contradict Matlab's own documentation. At http://www.mathworks.com/help/matlab/matlab_external/handling-data-returned-from-a-java-method.html#f61197 they explicitly say

> When a method call returns data of type java.lang.Object,
> MATLAB converts its value, depending on its actual type,
> according to the following table.

and says that a Java return value of java.lang.String should be auto-converted into a Matlab type char value. Unless I'm completely misunderstanding that page. What version of Matlab did you observe this in? Any different result with

Mike Miller <mtmiller>
Project Administrator
Mon 07 Jul 2014 09:49:25 PM UTC, original submission:

Java objects have a "toString" which returns a java.lang.String object. However, calling this method via Octave returns an Octave char. Example:

while in Matlab:

Carnë Draug <carandraug>
Project Member


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

Attach Files:

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

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

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-04-27 mtmiller StatusNeed Info => Confirmed
        Release3.8.1 => dev
    2014-07-10 mtmiller CategoryNone => Libraries
        Item GroupNone => Matlab Compatibility
        StatusNone => Need Info

    Back to the top

    Powered by Savane 3.3