Unbounded wildcards in Collections and Maps #112
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Generics: use unbounded wildcards instead of Object as generic type.
There is a JSONArray constructor with
(Collection <Object> c)and another constructor with signature(Object o). A call withnew JSONArray(new HashSet<Something>())will not resolve to thefirst constructor, but to the second one. This broke our code when we tried to upgrade from
an older JSON-java version.
There is a similar issue which concerns Maps. Maps with
<?,?>instead of<String, Object>type parameters should be used. So maximum flexibility is gained for the callers.For details, please refer to example 4.5.1.1. in the java language reference
http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.5.1
Very much appreciate your efforts.
P.S.: just saw the very similar pull request (#111 from @domusofsail).
While i do believe that the changes in my request are a little bit more
complete than the ones incorporated in #111, the remarkable timely coincidence of the two
requests signifies that the principal issue is legitimate.