[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #59088] Failing java.lang.Float BIST test in o
From: |
Philip Nienhuis |
Subject: |
[Octave-bug-tracker] [bug #59088] Failing java.lang.Float BIST test in ov-java.cc |
Date: |
Wed, 9 Sep 2020 13:50:51 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0 |
URL:
<https://savannah.gnu.org/bugs/?59088>
Summary: Failing java.lang.Float BIST test in ov-java.cc
Project: GNU Octave
Submitted by: philipnienhuis
Submitted on: Wed 09 Sep 2020 07:50:50 PM CEST
Category: Libraries
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Unexpected Error or Warning
Status: Patch Submitted
Assigned to: None
Originator Name: Philip Nienhuis
Originator Email:
Open/Closed: Open
Release: dev
Discussion Lock: Any
Operating System: Any
_______________________________________________________
Details:
Running __run_test_suite__.m in dev Octave (hg id eb35003c3851) on a Win10
system with Java 10 I see the following failing test in fntests.log:
>>>>> processing
L:\philip\devel\octdev\mxe\mxe_64w_20200818D\dist\octave7\mingw64\share\octave\7.0.0\etc\tests\libinterp\octave-value\ov-java.cc-tst
***** testif HAVE_JAVA; usejava ("jvm")
n = javaObject ("java.lang.Float", 1.35);
assert (n.compareTo (1.0), 1);
assert (n.compareTo (1.35), 0);
assert (n.compareTo (10), -1);
assert (n.doubleValue (), 1.35, 1e7);
!!!!! test failed
[java] java.lang.ClassCastException: class java.lang.Double cannot be cast to
class java.lang.Float (java.lang.Double and java.lang.Float are in module
java.base of loader 'bootstrap')
This is probably due to Java 10 being stricter than Java 8 (on my Linux build
systems: OpenJDK Runtime Environment, build 1.8.0_262-b10); the "compareTo()"
method now only accepts arguments of equal type. So for said test it can only
compare variable "n" to a Java float value, or an Octave single.
Even though I initially wrote the test (8b5bc5e5f74b) I'm unsure what it was
meant to check exactly. Assuming it is meant to check that javaObject can
actually produce a Java float with numeric value 1.35, the following
(admittedly fairly convoluted) code seems to work better:
n = javaObject ("java.lang.Float", 1.35);
n.compareTo (single (javaObject ("java.lang.Integer", 1).floatValue ())) #
1
n.compareTo (single (javaObject ("java.lang.Double", 1.35).floatValue ())) #
0
n.compareTo (single (javaObject ("java.lang.Double", 10).floatValue ())) #
-1
Patch along those lines attached.
Note that I got this with dev Octave, but I expect it to also fail on stable
Octave (6.0.90) with Java 10 as ov-java.cc is essentially the same w.r.t.
numerics processing for stable and dev Octave.
FWIW, the above code won't run on Matlab as that complains about "Undefined
variable 'javaObject' or class 'javaObject'". Maybe Octave's boxing/unboxing
works differently or Matlab's parser gets confused.
In Octave the "cast" to single is required because in ov-java.cc all numeric
scalar Java types are converted to Octave doubles; and an ensuing ".floatValue
()" method produces a scalar numeric Java value as well:
>> class (javaObject ("java.lang.Double", 10).floatValue ())
ans = double
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Wed 09 Sep 2020 07:50:50 PM CEST Name: ov-java_cc_float-BIST.patch
Size: 764B By: philipnienhuis
<http://savannah.gnu.org/bugs/download.php?file_id=49772>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?59088>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #59088] Failing java.lang.Float BIST test in ov-java.cc,
Philip Nienhuis <=