octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #48819] java interface: set String[] fails


From: Ernst Reissner
Subject: [Octave-bug-tracker] [bug #48819] java interface: set String[] fails
Date: Thu, 18 Aug 2016 17:41:32 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0

URL:
  <http://savannah.gnu.org/bugs/?48819>

                 Summary: java interface: set String[] fails
                 Project: GNU Octave
            Submitted by: ernstreissner
            Submitted on: Thu 18 Aug 2016 05:41:29 PM GMT
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

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.









    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 18 Aug 2016 05:41:29 PM GMT  Name: OctaveInterfaceTester.java  Size:
5kB   By: ernstreissner

<http://savannah.gnu.org/bugs/download.php?file_id=38257>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48819>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]