bugGNU Octave - Bugs: bug #59244, class java.lang.Double cannot be...

 
 

bug #59244: class java.lang.Double cannot be cast to class java.lang.Float

Submitted by:  Dmitri A. Sergatskov <dasergatskov>
Submitted on:  Fri 09 Oct 2020 07:11:25 PM UTC  
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Duplicate Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  6.0.90 Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

( Jump to the original submission)

Fri 09 Oct 2020 08:33:12 PM UTC, comment #11: 

Thanks.

Closing as duplicate of bug #51804.

Markus Mützel <mmuetzel>
Project Member
Fri 09 Oct 2020 08:29:34 PM UTC, comment #10: 


octave:9> n = javaObject ("java.lang.Float", 1.35)
n =

<Java object: java.lang.Float>

octave:10> m = methods (n, '-full')
m =
{
  [1,1] = Float(java.lang.String) throws java.lang.NumberFormatException
  [2,1] = Float(double)
  [3,1] = Float(float)
  [4,1] = boolean equals(java.lang.Object)
  [5,1] = java.lang.String toString(float)
  [6,1] = java.lang.String toString()
  [7,1] = int hashCode()
  [8,1] = int hashCode(float)
  [9,1] = float min(float, float)
  [10,1] = float max(float, float)
  [11,1] = int floatToRawIntBits(float)
  [12,1] = int floatToIntBits(float)
  [13,1] = float intBitsToFloat(int)
  [14,1] = int compareTo(java.lang.Object)
  [15,1] = int compareTo(java.lang.Float)
  [16,1] = byte byteValue()
  [17,1] = short shortValue()
  [18,1] = int intValue()
  [19,1] = long longValue()
  [20,1] = float floatValue()
  [21,1] = double doubleValue()
  [22,1] = java.lang.Float valueOf(float)
  [23,1] = java.lang.Float valueOf(java.lang.String) throws java.lang.NumberFormatException
  [24,1] = java.lang.String toHexString(float)
  [25,1] = int compare(float, float)
  [26,1] = java.lang.Object resolveConstantDesc(java.lang.invoke.MethodHandles.Lookup) throws java.lang.ReflectiveOperationException
  [27,1] = java.lang.Float resolveConstantDesc(java.lang.invoke.MethodHandles.Lookup)
  [28,1] = java.util.Optional describeConstable()
  [29,1] = boolean isNaN(float)
  [30,1] = boolean isNaN()
  [31,1] = float parseFloat(java.lang.String) throws java.lang.NumberFormatException
  [32,1] = boolean isInfinite()
  [33,1] = boolean isInfinite(float)
  [34,1] = boolean isFinite(float)
  [35,1] = float sum(float, float)
  [36,1] = void wait(long, int) throws java.lang.InterruptedException
  [37,1] = void wait() throws java.lang.InterruptedException
  [38,1] = void wait(long) throws java.lang.InterruptedException
  [39,1] = java.lang.Class getClass()
  [40,1] = void notify()
  [41,1] = void notifyAll()
}

Dmitri A. Sergatskov <dasergatskov>
Fri 09 Oct 2020 08:16:30 PM UTC, comment #9: 

I installed Java on my Ubuntu 20.04:

>> version -java
ans = Java 11.0.8+10-post-Ubuntu-0ubuntu120.04 with Ubuntu OpenJDK 64-Bit Server VM mixed mode, sharing

The test in comment #0 is working for me with that version.

fwiw:

>> n = javaObject ("java.lang.Float", 1.35)
>> m = methods (n, '-full')
m =
{
  [1,1] = Float(java.lang.String) throws java.lang.NumberFormatException
  [2,1] = Float(double)
  [3,1] = Float(float)
  [4,1] = boolean equals(java.lang.Object)
  [5,1] = java.lang.String toString(float)
  [6,1] = java.lang.String toString()
  [7,1] = int hashCode()
  [8,1] = int hashCode(float)
  [9,1] = float min(float, float)
  [10,1] = float max(float, float)
  [11,1] = int floatToRawIntBits(float)
  [12,1] = int floatToIntBits(float)
  [13,1] = float intBitsToFloat(int)
  [14,1] = int compareTo(java.lang.Float)
  [15,1] = int compareTo(java.lang.Object)
  [16,1] = byte byteValue()
  [17,1] = short shortValue()
  [18,1] = int intValue()
  [19,1] = long longValue()
  [20,1] = float floatValue()
  [21,1] = double doubleValue()
  [22,1] = java.lang.Float valueOf(float)
  [23,1] = java.lang.Float valueOf(java.lang.String) throws java.lang.NumberFormatException
  [24,1] = java.lang.String toHexString(float)
  [25,1] = int compare(float, float)
  [26,1] = boolean isNaN(float)
  [27,1] = boolean isNaN()
  [28,1] = float parseFloat(java.lang.String) throws java.lang.NumberFormatException
  [29,1] = boolean isInfinite(float)
  [30,1] = boolean isInfinite()
  [31,1] = boolean isFinite(float)
  [32,1] = float sum(float, float)
  [33,1] = void wait(long) throws java.lang.InterruptedException
  [34,1] = void wait(long, int) throws java.lang.InterruptedException
  [35,1] = void wait() throws java.lang.InterruptedException
  [36,1] = java.lang.Class getClass()
  [37,1] = void notify()
  [38,1] = void notifyAll()
}

If "int compareTo(java.lang.Object)" appears before "int compareTo(java.lang.Float)" for you, I'm pretty sure this is bug #51804.

Markus Mützel <mmuetzel>
Project Member
Fri 09 Oct 2020 08:11:01 PM UTC, comment #8: 

Probably this will show the signatures:

x = javaObject ("java.lang.Float", 0)
m = methods (x, "-full")

Markus Mützel <mmuetzel>
Project Member
Fri 09 Oct 2020 08:05:54 PM UTC, comment #7: 

Hmmm. That looks different from https://savannah.gnu.org/bugs/?51804#comment6
Maybe like this?

x = javaObject ("java.lang.Float", 0)
m = methods (x)

Which command is even raising the error?
Does the following work if you execute it line by line? Which lines fail?

n = javaObject ("java.lang.Float", 1.35)
n.compareTo (single (1.0))
n.compareTo (1.0)

Markus Mützel <mmuetzel>
Project Member
Fri 09 Oct 2020 08:01:07 PM UTC, comment #6: 

This was on Fedora 33 (beta), hg id d7169f012ee1 (stable)

 java --version
openjdk 15 2020-09-15
OpenJDK Runtime Environment 20.9 (build 15+36)
OpenJDK 64-Bit Server VM 20.9 (build 15+36, mixed mode, sharing)

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 09 Oct 2020 07:57:58 PM UTC, comment #5: 

octave:2> x = javaObject ("java.lang.Float", 0)
x =

<Java object: java.lang.Float>

octave:3> methods (x)
Methods for class java.lang.Float:
Float                doubleValue          getClass             isInfinite           notify               sum
byteValue            equals               hashCode             isNaN                notifyAll            toHexString
compare              floatToIntBits       intBitsToFloat       longValue            parseFloat           toString
compareTo            floatToRawIntBits    intValue             max                  resolveConstantDesc  valueOf
describeConstable    floatValue           isFinite             min                  shortValue           wait

octave:5> n  = javaObject ("java.lang.Float", single (1.35))
n =

<Java object: java.lang.Float>

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 09 Oct 2020 07:52:51 PM UTC, comment #4: 

I don't know much about Java or where to even start looking to fix this.

To test if this is bug #51804, what does the following return for you?

x = javaObject ("java.lang.Float", 0)
methods (x)

Looks like in bug #53728 it was determined that it is a duplicate of bug #51804...

Does the following raise the same error?

n = javaObject ("java.lang.Float", single (1.35));

Markus Mützel <mmuetzel>
Project Member
Fri 09 Oct 2020 07:39:25 PM UTC, comment #3: 

There is also bug #53728 ...

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 09 Oct 2020 07:35:24 PM UTC, comment #2: 

It looks similar but it is also different.
Are we sticking with 1.8.0 for now?

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 09 Oct 2020 07:29:15 PM UTC, comment #1: 

This looks very similar to bug #51804 that you reported a while back.
Is it a duplicate?

Markus Mützel <mmuetzel>
Project Member
Fri 09 Oct 2020 07:11:25 PM UTC, original submission:  

With java 14 and 15 i get:

octave:1>  test 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')

That was OK with java 1.8.0

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2020-10-09 mmuetzel StatusNone => Duplicate
        Open/ClosedOpen => Closed
        Dependencies- => Depends on bugs #51804

    Back to the top


    Powered by Savane 3.7