bugGNU Octave - Bugs: bug #59088, Failing java.lang.Float BIST test...

 
 

bug #59088: Failing java.lang.Float BIST test in ov-java.cc

Submitted by:  Philip Nienhuis <philipnienhuis>
Submitted on:  Wed 09 Sep 2020 05:50:50 PM UTC  
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Duplicate Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

Thu 10 Sep 2020 05:36:46 AM UTC, comment #2: 

Thanks, ISTR some messages but for some reason my seach for ov-java.cc didn't turn them up; PEBCAK I fear.
I'll post further in bug #51804

Philip Nienhuis <philipnienhuis>
Project Member
Wed 09 Sep 2020 08:41:51 PM UTC, comment #1: 

Looks like a duplicate of bug #53728 and bug #57619 which were closed as a duplicates of bug #51804.

Closing as duplicate, too. But please re-open if you think this is something different.

Markus M├╝tzel <mmuetzel>
Project Member
Wed 09 Sep 2020 05:50:50 PM UTC, original submission:  

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

Philip Nienhuis <philipnienhuis>
Project Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by philipnienhuis (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-09-09 mmuetzel StatusPatch Submitted => Duplicate
        Open/ClosedOpen => Closed
        Dependencies- => Depends on bugs #57619
        Dependencies- => Depends on bugs #53728
        Dependencies- => Depends on bugs #51804
    2020-09-09 philipnienhuis Attached File- => Added ov-java_cc_float-BIST.patch, #49772

    Back to the top


    Powered by Savane 3.5