Task for an aspiring JDK contributor

Ethan McCue ethan at mccue.dev
Fri Nov 18 16:43:45 UTC 2022


new ArrayList<>(Arrays.asList(theArray));

I'm not intending to be pithy - just this is one of the "known
deficiencies" of the collections framework. If you look hard enough you can
find some spitballing I did on how to address it in the core-libs mailing
list (which would be the place to go for this sort of stuff - cc-ing).

The internal class names aren't trivial to fix either because someone
somewhere has serialized a java.util.Arrays$ArrayList using
ObjectOutputStream and wants to read it back out at some point. Not
impossible to address, just tricky.

What is the situation where you encountered the internal class name? It
could be worth it to make it more clear in whatever that debug scenario is.

---

Other than that, to contribute code to the JDK you need to sign the OCA. It
will take a bit so you should get that out of the way.

On Fri, Nov 18, 2022 at 11:29 AM Andreas Røsdal <andreas.rosdal at gmail.com>
wrote:

> Yes, the exception comes when adding objects to the returned list. So I
> would like a convenient way to use Arrays to convert an array to a normal
> modifiable java.util.ArrayList, instead of this AbstractList.
>
>
> On Fri, Nov 18, 2022 at 5:23 PM Ethan McCue <ethan at mccue.dev> wrote:
>
>> What situation were you encountering the exception? Was it when trying to
>> add to the returned list?
>>
>> If so, that's expected. Arrays.asList only wraps an underlying array, it
>> can't grow it. By that measure List.of() is even more unintuitive because
>> you can't set anything.
>>
>> On Fri, Nov 18, 2022, 11:06 AM Andreas Røsdal <andreas.rosdal at gmail.com>
>> wrote:
>>
>>> Hello!
>>>
>>> I am an aspiring JDK contributor, having used Java in my work as a
>>> developer.
>>>
>>> I was recently surprised by an Exception thrown when using the
>>> java.util.Arrays.asList() method
>>> so I would like to propose some improvements to this API. In particular:
>>> - When using java.util.Arrays.asList() then AbstractList is throwing UnsupportedOperationException
>>> which is not user-friendly or intuitive.
>>> -  java.util.Arrays.asList() returning a private class called ArrayList,
>>> which is not the usual java.util.ArrayList, so it's not user-friendly or
>>> intuitive.
>>>
>>> Since this would be my first contribution to the JDK, and the goal is to
>>> complete the contribution with accepted pull request and get the Arrays API
>>> improved, what would the first step to making this first improvement to the
>>> JDK be?
>>>
>>> I would also like to share a link to an open source project I've been
>>> working on:
>>> https://github.com/fciv-net/fciv-net
>>>
>>> Thank you!
>>>
>>> Regards,
>>> Andreas R.
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20221118/8768d8cd/attachment.htm>


More information about the core-libs-dev mailing list