[PROPOSAL][JDK10] Introduce Executable.getParameterType(index)
john.r.rose at oracle.com
Thu Nov 2 19:56:04 UTC 2017
On Oct 20, 2017, at 4:45 AM, Christoph Dreis <christoph.dreis at freenet.de> wrote:
> What do you think about that? Is someone willing to sponsor this given it's
> considered worthwhile.
Let's set that up on top of the new unmodifiable lists from List.of.
It will be simpler and more powerful in the end. Coding with
the new unmodifiable collections is really nice, and we should
So for every old-school access method of the form T getFoos(),
let's consider adding List<T> getFooList(), which returns a list
that works like List.of. If we use a shared-secrets mechanism,
we can even reuse the same List.of code, using a private
API List.ofSharedArray(T) which doesn't copy the argument..
P.S. A couple thoughts on naming:
Ultimately it would be good if we could do overload selection
based on return type, in which case we wouldn't have to change
the name of the T access functions, just their return types.
If we *are* going to change names, we might consider a more
modern-looking form for immutable getters, which elides that
grody "get" prefix. The "get" prefix makes the most sense when
there is a possibility of a corresponding "set" operator, but these
data structures have no setters, since they are unmodifiable.
The "get" prefix is notably absent from the java.lang.invoke
APIs, except where there really are setters present also.
I wish we could decide to adopt that convention more widely.
More information about the core-libs-dev