bugGNU Octave - Bugs: bug #51804, java-9: java.base/java.lang.Double...

 
 

bug #51804: java-9: java.base/java.lang.Double cannot be cast to java.base/java.lang.Integer

Submitted by:  Dmitri A. Sergatskov <dasergatskov>
Submitted on:  Sun 20 Aug 2017 06:22:45 PM UTC  
 
Category: Test SuiteSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Unexpected Error
Status: Need InfoAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating 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 Jump to the original submission)

Sun 20 Aug 2017 09:12:58 PM UTC, comment #7:

It's not documented, I can only guess that the Comparable<T> interface also defines a compareTo(Object) method that internally tries to cast the object to type T.

Mike Miller <mtmiller>
Project Administrator
Sun 20 Aug 2017 08:59:59 PM UTC, comment #6:

Ok, this may be the problem

With Java 8, the list contains

in that order. So when Octave iterates through the available methods, it finds the Integer one first, and everything works as expected. With Java 9, I get the following

in the opposite order. Octave finds the one that takes an Object first, assumes that that should work when given a double-valued argument, and calls it. If that method actually exists and works, then this should work. But it's like Java is reporting that this compareTo(Object) method exists, but when it's called it is actually calling the one that takes an Integer.

Mike Miller <mtmiller>
Project Administrator
Sun 20 Aug 2017 08:45:39 PM UTC, comment #5:

I don't see any difference in the API, both Java 8 and 9 say that java.lang.Integer.compareTo takes java.lang.Integer as an argument. However, when Octave is inspecting the runtime for the method "compareTo", the result says that it takes an argument of type java.lang.Object, not Integer. Octave doesn't do any casting because it doesn't think it has to, but then when the method is called the exception is thrown.

Someone might want to look into the Java 9 runtime in more detail and find out why this is happening. I think it will take writing some Java code to iterate over the available methods in the Integer class and see what's different.

Mike Miller <mtmiller>
Project Administrator
Sun 20 Aug 2017 06:37:59 PM UTC, comment #4:

Sorry -- the comments 1 and 2 crossed over in the ether.
I am looking at

but so far have not seen any relevant info.
I guess it could be a bug in the RC.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sun 20 Aug 2017 06:30:04 PM UTC, comment #3:

Sure, but I'd rather understand why the call isn't working the way it is.

In Java 9 I can construct an Integer with a double, and I can call compareTo with a double argument. I would like to know where Java 9 has changed something so that that is no longer possible. Particularly since Java 9 isn't actually released yet.

Mike Miller <mtmiller>
Project Administrator
Sun 20 Aug 2017 06:27:42 PM UTC, comment #2:

Changing "assert(...)" call to:

makes it pass
(those are failing test in libinterp/octave-value/ov-java.cc-tst)

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sun 20 Aug 2017 06:26:16 PM UTC, comment #1:

I saw this also when trying to build with Java 9. Do you know where the relevant change in the Java 9 API is?

Mike Miller <mtmiller>
Project Administrator
Sun 20 Aug 2017 06:22:45 PM UTC, original submission:

dev version compiled against java-9
(java-9-openjdk-9.0.0.181-1)

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by dasergatskov (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 20 Aug 2017 06:30:04 PM UTCmtmillerItem GroupNone=>Unexpected Error
      StatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1