typeof Long is not 'number' anymore
Frantzius, Jörg
Joerg.Frantzius at aperto.com
Wed Oct 12 14:10:47 UTC 2016
Hi,
as of JDK 1.8.0_101, the following JUnit test fails:
@Test
public void testLongIsNumber() {
jdk.nashorn.api.scripting.ScriptObjectMirror isNumberFunction = eval("function isNumber(arg) {\n" +
" return typeof arg === 'number';\n" +
"}\n" +
"");
Object result = isNumberFunction.call(isNumberFunction, 1L);
assertTrue((boolean) result);
}
This breaks e.g. Nodyn, where Long numbers resulting from java.io.File.length() are passed into https://nodejs.org/api/util.html#util_util_isnumber_object , resulting in some „if" clause now taking the wrong turn. I guess this is a side-effect of https://bugs.openjdk.java.net/browse/JDK-8144020 .
While I’m probably able to patch this in Nodyn, I find it a bit frightening that any other code out there that relies on Longs being typeof ‚number‘ will break now, in particular because there is a lot of JDK API that returns Long...
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