-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
19.2.0 Date interop not working #200
Comments
I'm currently facing the same issue and was wondering if you have an example of your Cheers and thanks, |
Hi @Biglr , For the JS->Java direction, we use something like this (note
Cheers, |
Thank you very much for your reply! I was fiddling around with
however, this never worked and just ignored the mapping no matter what i set for I guess the critical point was to not only specify I'll stick to your implementation though, since it offers much more extensibility 😉 Thank you once again very much, you saved me a lot time and headaches 😀 Cheers, |
Java->JS interop is still mostly broken. Using 20.2.0, it looks like JSRuntime.toPrimitiveFromForeign doesn't handle Date/Instance correctly and calls toString and tries to coerce it to a double. When I try to use the Intl library for formatting a straight ProxyDate, it gives a rangeError. If my ProxyDate implements ProxyObject and implements toString as the same as getTime, it works, but it's incorrect. Date.toString() should return a formatted date and not the epoch date. JSRuntime.toPrimitiveFromForeign should check InteropLibrary.isDate/isInstant/etc. and then call the appropiate method. You can validate it by running
It returns
instead of properly coercing as a JSDate |
Hi @steventamm For Java -> JS we use something like this as a workaround:
|
Hi,
I'm trying to use the new date interop in 19.2.0, but having issues in both directions across the Javascript/Java boundary:
Date
if I explicitly usevalue.as(Date.class)
. However,value.as(Object.class)
instead gives me an emptyMap
. The workaround for this is to use theHostAccessBuilder#targetTypeMapping
feature.Date
in java, it's not seen as a JS Date in Javascript. ImplementingProxyInstant
/ProxyDate
does not change this. And there is no Java-JS type mapping (see Custom Java -> JS Conversion #144). Thus I still need to continue to use my own DateProxy (aProxyObject
that exposes agetTime
member as aProxyExecutable
).Here is a testng test in Groovy that demonstrates the issues:
The text was updated successfully, but these errors were encountered: