Details
-
Bug
-
Resolution: Fixed
-
P3
-
None
-
None
-
b113
-
generic
-
generic
Description
- There's now an overloaded method ambiguity when selecting between e.g. String and String[]. We solve it by having a preference for arrays when we are converting a native array. More precisely, we need to have a preference for List and Deque, and then for arrays.
- We were getting a warning from Guards.isInstance linking that in some cases we were creating a test that always evaluates to false. It needs an adjustment in Dynalink's SimpleDynamicMethod when it's linking variable arity methods and there's exactly one argument for the vararg position. There, Dynalink has to decide whether to treat that last argument as being the vararg array itself, or as being the single element of the vararg array.
Now, this particular issue (vararg special case with 1 argument in vararg array position) has some deeper implications in conjunction with automatic array conversions in Nashorn. Namely, what to do when a NativeArray is passed as a parameter here? Currently, Dynalink doesn't use language-specific conversions when considering this parameter. It *could*, but then since we can now convert *any* JS object to a Java array, we'd end up converting any object passed there to an array - even functions.
Possible approaches here are:
- leave it as it is. Passing a single NativeArray in the vararg array parameter position will still require explicit Java.to().
- let Dynalink apply language-specific conversions to the values in the vararg array parameter position. In this case, however, we'll have to narrow down the automatic conversion to arrays to only apply to NativeArray class and nothing else. This actually seems reasonable (array-like objects that aren't actual arrays won't be automatically converted in any position anymore, but NativeArrays in vararg parameter position will). If we wouldn't narrow the automatic conversion to NativeArray only, then we'd be in for nasty surprise e.g. in test/script/basic/
Attachments
Issue Links
- relates to
-
JDK-8026113 Nashorn arrays should automatically convert to Java arrays
- Resolved