bugGNU Octave - Bugs: bug #48819, java interface: set String[] fails

 
 

bug #48819: java interface: set String[] fails

Submitter:  Ernst Reissner <ernstreissner>
Submitted:  Thu 18 Aug 2016 05:41:29 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 18 Aug 2016 05:41:29 PM UTC, original submission:  

With the java class attached, try:


t=javaObject('eu.simuline.octave.OctaveInterfaceTester')


Of course t.aStr returns null, i.e. [], because not initialized.
Initialize in the following way:

arr=javaArray('java.lang.String',3)
arr(1)='xx'
arr(2)='yy'
arr(3)='zz'
t.aStr=arr


and check:

t.aStr


which really yields

ans =
<Java object: java.lang.String[]>


So all ok until now.
Normally, it should be much easier to initialize t.aStr.
Try

t.aStr=['ab';'cd';'ef']

which should initialize with another String[], namely['ab';'cd';'ef'] according to
http://de.mathworks.com/help/matlab/matlab_external/passing-data-to-a-java-method.html

but trying

t.aStr


yields

ans = [](0x0)

representing the null-value.
This is easy to see:
ClassHelper.castArgument just returns null if it cannot cast.
That way, the field becomes initialized with null.

This works for all reference types because for these null is untyped.
So, the bug is hidden.
It would be better to throw a ClassCastException in ClassHelper.castArgument.





Ernst Reissner <ernstreissner>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #38257:  OctaveInterfaceTester.java added by ernstreissner (5KiB - application/x-java)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Updated the item)
  • -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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-18 mtmiller CategoryNone Octave Function
        Item GroupNone Incorrect Result
    2016-08-18 ernstreissner Attached File- Added OctaveInterfaceTester.java, #38257
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-4b4b.
    Corresponding source code