Title: varargs ambiguity with generics · Issue #285 · joeferner/node-java · GitHub
Open Graph Title: varargs ambiguity with generics · Issue #285 · joeferner/node-java
X Title: varargs ambiguity with generics · Issue #285 · joeferner/node-java
Description: > var Arrays = java.import('java.util.Arrays'); > var list = Arrays.asList(['a', 'b']); > list.toArray(); [ [ 'a', 'b' ] ] // should be ['a', 'b'] !! I haven't looked at the varargs handling code, but I'm assuming it's because of the amb...
Open Graph Description: > var Arrays = java.import('java.util.Arrays'); > var list = Arrays.asList(['a', 'b']); > list.toArray(); [ [ 'a', 'b' ] ] // should be ['a', 'b'] !! I haven't looked at the varargs handling code, ...
X Description: > var Arrays = java.import('java.util.Arrays'); > var list = Arrays.asList(['a', 'b']); > list.toArray(); [ [ 'a', 'b' ] ] // should be ['a'...
Opengraph URL: https://github.com/joeferner/node-java/issues/285
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"varargs ambiguity with generics","articleBody":"```\n\u003e var Arrays = java.import('java.util.Arrays'); \n\u003e var list = Arrays.asList(['a', 'b']);\n\u003e list.toArray();\n[ [ 'a', 'b' ] ] // should be ['a', 'b'] !!\n```\n\nI haven't looked at the varargs handling code, but I'm assuming it's because of the ambiguity due to the `asList` method being generic (`List\u003cT\u003e asList(T... a)`) - there's no way to distinguish if the javascript Array being passed into Arrays.asList() is intended as a single value of type `T` or if it's intended as a `T[]`. \n\nAssuming that's the issue, we could detect this ambiguity and throw an error, requiring the javascript programmer to use apply when they want a javascript array to be 'spread' into a varargs generic function. \n\nDoes this make sense?\n\n(Btw, ES6 compiled by babel works just fine here with `Arrays.asList(...arr);`).\n","author":{"url":"https://github.com/henridf","@type":"Person","name":"henridf"},"datePublished":"2015-12-03T06:55:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/285/node-java/issues/285"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:60a3e610-a4c0-5742-6fd8-93a588b4b7aa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A8AC:2B0240:5BA57E:7D6D1D:6969D9F8 |
| html-safe-nonce | e416c9b2b6e71cd79e07a909b554fdfc3f963271c4c00947a112b1f026fea2cd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOEFDOjJCMDI0MDo1QkE1N0U6N0Q2RDFEOjY5NjlEOUY4IiwidmlzaXRvcl9pZCI6Ijc4ODk1MTc2ODM2ODg0NjI4NDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 792ca8af3b6d38428b53bc41697dbf52cfce6c888e8ed84f0859238c8e369fcc |
| hovercard-subject-tag | issue:120106997 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/joeferner/node-java/285/issue_layout |
| twitter:image | https://opengraph.githubassets.com/673da7898308a5808e04384bf4550aa66ed674ca48c66bc4a6b83ce871720e54/joeferner/node-java/issues/285 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/673da7898308a5808e04384bf4550aa66ed674ca48c66bc4a6b83ce871720e54/joeferner/node-java/issues/285 |
| og:image:alt | > var Arrays = java.import('java.util.Arrays'); > var list = Arrays.asList(['a', 'b']); > list.toArray(); [ [ 'a', 'b' ] ] // should be ['a', 'b'] !! I haven't looked at the varargs handling code, ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | henridf |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| go-import | github.com/joeferner/node-java git https://github.com/joeferner/node-java.git |
| octolytics-dimension-user_id | 808857 |
| octolytics-dimension-user_login | joeferner |
| octolytics-dimension-repository_id | 3228734 |
| octolytics-dimension-repository_nwo | joeferner/node-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3228734 |
| octolytics-dimension-repository_network_root_nwo | joeferner/node-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width