Integer add operation now yields Double instead of Long with JDK 1.8.0_101?

Attila Szegedi szegedia at gmail.com
Thu Sep 29 20:29:07 UTC 2016


It’s an intentional change, see https://bugs.openjdk.java.net/browse/JDK-8144020 <https://bugs.openjdk.java.net/browse/JDK-8144020>.

Attila.

> On 29 Sep 2016, at 18:30, Frantzius, Jörg <Joerg.Frantzius at aperto.com> wrote:
> 
> Hi,
> 
> we have a JUnit test that first evaluates a Javascript file containing this:
> 
> function add(a, b) {
>    return a + b;
> }
> 
> The Java JUnit test itself then evaluates
> 
> engine.eval("add(4, 5)")
> 
> Just until 1.8.0_91, this used to return a 9L Long number. With 1.8.0_101, this suddenly returns a Double object 9D.
> 
> When directly evaluating the addition operation:
> 
> eval("4 + 5")
> 
> an Integer 9 is returned, both with 1.8.0_101 and 1.8.0_91.
> 
> Is this intended behaviour, or is this a bug?
> 
> Thx for responses + regards,
> Jörg
> 
> 
> ---
> 
> Dipl. Inf. Jörg von Frantzius, Technical Director
> 
> E-Mail joerg.frantzius at aperto.com
> 
> Phone +49 30 283921-318
> Fax +49 30 283921-29
> 
> Aperto AG – An IBM Company
> Chausseestraße 5, D-10115 Berlin
> http://www.aperto.com<http://www.aperto.de/>
> http://www.facebook.com/aperto
> https://www.xing.com/companies/apertoag
> 
> HRB 77049 B, AG Berlin Charlottenburg
> Vorstand: Dirk Buddensiek (Vorsitzender), Kai Großmann, Stephan Haagen, Daniel Simon
> Aufsichtsrat: Matthew Candy (Vorsitzender)
> 



More information about the nashorn-dev mailing list