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

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

[Octave-bug-tracker] [bug #44882] java arrays are not automatically conv


From: Carnë Draug
Subject: [Octave-bug-tracker] [bug #44882] java arrays are not automatically converted to octave types
Date: Mon, 20 Apr 2015 23:38:49 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.6.0

Follow-up Comment #5, bug #44882 (project octave):

While testing my patch, I found another problem with the way that even scalars
are handled.  The problem is that all scalar integers are converted to Integer
(int32) even when this is not possible (seems like it croaks when casting Byte
into Integer).


octave> javaMethod ("binarySearch", "java.util.Arrays", int8 ([90 95 100]),
int8 (95));
error: [java] java.lang.ClassCastException: java.lang.Integer cannot be cast
to java.lang.Byte


Previously this was also not working, but after this patch, the vector gets
casted into a Byte[] so now fails on the second conversion.  The problem is
that *all* integer scalars are getting converted into an Integer:

http://hg.savannah.gnu.org/hgweb/octave/file/ddc5c7663329/libinterp/octave-value/ov-java.cc#l1292

which then fails when calling the actual method:

http://hg.savannah.gnu.org/hgweb/octave/file/ddc5c7663329/libinterp/octave-value/ov-java.cc#l1822

I checked with Matlab and it seems to cast down uint8 into int8, even if
requires losing data.

The new attached patch, fixes all this in 4 cset and also adds tests which got
run in Matlab 2010b



(file #33729)
    _______________________________________________________

Additional Item Attachment:

File name: convert-java-primitive-arrays.cset Size:13 KB


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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