oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.28k stars 1.63k forks source link

[host interop] Correct host method no longer found #2978

Closed fniephaus closed 3 years ago

fniephaus commented 3 years ago

Describe GraalVM and your environment :

Have you verified this issue still happens when using the latest snapshot? Yes.

Describe the issue Precedence for target type mappings has recently been implemented. It looks like this is causing host method lookups issues. The below is an example that worked fine on CE 20.1.

Code snippet or code repository that reproduces the issue

$ bin/polyglot --jvm --shell
GraalVM MultiLanguage Shell 21.0.0-dev
Copyright (c) 2013-2020, Oracle and/or its affiliates
  JavaScript version 21.0.0-dev
js> let now = Java.type('java.time.Instant').now()
js> let zoneId = Java.type('java.time.ZoneId').systemDefault()
js> zoneId.getRules()
JavaObject[java.time.zone.ZoneRules]
js> zoneId.getRules().getOffset(now)
TypeError: invokeMember (getOffset) on java.time.zone.ZoneRules@82c57b3 failed due to:
Multiple applicable overloads found for method name getOffset (
candidates:[
Method[public java.time.ZoneOffset java.time.zone.ZoneRules.getOffset(java.time.Instant)],
Method[public java.time.ZoneOffset java.time.zone.ZoneRules.getOffset(java.time.LocalDateTime)]],
arguments:[
JavaObject[2020-11-12T14:04:00.867909Z (java.time.Instant)] (HostObject)])

Please assign to @chumer.

woess commented 3 years ago

Thanks for the report! Fixed in master (https://github.com/oracle/graal/commit/8e2fcd121d4ec26ae9980efb1d5ebecc3b2ac083). Unfortunately the fix won't make it into 20.3.0 anymore but it will be part of 20.3.1 and 21.0.0.

fniephaus commented 3 years ago

Thanks a lot, @woess. No worries, great it is fixed now!