-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Painless still cannot understand some overloaded methods #22177
Comments
@jdconrad any thoughts? |
A couple of quick notes: Edit: Oops! I just realized that BitSet is already part of our whitelist, so I'm editing my comment to make sense. Overloading has been supported since our initial release of painless in 5.0, but only by arity, not by signature. We decided early on in development to go with arity overloading (meaning methods with the same name must have a different number of arguments) because it turns out it's really difficult to determine method overloading at runtime without at least taking a significant performance hit. I'll see if I can figure out why we went with valueOf(long[]) instead of valueOf(byte[]). Maybe this is something that should be changed. |
Thanks for that! |
Groovy has been deprecated in 5.0 and is removed in 6.0, so it's not really an option anymore just in case you were still looking into that. On a different note, after a bit of investigation, we went with long[] for performance reasons, but this is place where having byte[] also would be good, so I'll evaluate what our options are here to see if we can give you what you need. |
I got tripped up by |
@nezda -- Here is the published Painless API. (https://www.elastic.co/guide/en/elasticsearch/reference/master/painless-api-reference.html) @s1monw I'm not sure I consider this a bug since we claim to support arity overloading, it was a design decision made so method look up (especially for runtime performance) would be fast. Otherwise, we'd have to write our own algorithm for figuring out which method is closest to the passed in arguments which is both very difficult and bad for performance. This means we did have to make decisions around what methods were available that had the same arity within a separate class. I think an appropriate solution to this might be to alias some of the methods that share a name and arity to simply have a different name. |
This is not a bug. Painless uses arity overloading, but it's very unlikely we will ever support full signature overloading. Closing. |
Elasticsearch version: 5.0.1 and 5.1.1
Plugins installed: []
JVM version: 1.8.102
OS version: MacOS
Description of the problem including expected versus actual behavior:
When I write a script with code "BitSet.valueOf(some_byte_array)" I get ClassCastException with message byte[] cannot be cast to long[]. I think this happens because method valueOf is overloaded and first method in the overloaded method list uses long[] as method parameter.
I added java.util.BitSet class to whitelist for painless.
Expected: script execute the method so that instance of BitSet is created.
I found the issue #18385 and it should be fixed. I suspect that this fix was added to ES 5.x
Steps to reproduce:
The text was updated successfully, but these errors were encountered: