[PROPOSAL][JDK10] Introduce Executable.getParameterType(index)

John Rose john.r.rose at oracle.com
Thu Nov 2 21:34:15 UTC 2017

On Nov 2, 2017, at 1:33 PM, Christoph Dreis <christoph.dreis at freenet.de> wrote:
> Could you elaborate, please?

Sure.  It's really quite simple:  Replace the old mutable array
with a modern immutable list.

     * Returns a list of {@code Class} objects that represent the formal
     * parameter types, in declaration order, of the executable
     * represented by this object.  Returns a list of length
     * 0 if the underlying executable takes no parameters.
     * The list is immutable.
     * See <a href="../../util/List.html#immutable">Immutable List Static Factory Methods</a> for details.
     * @return the parameter types for the executable this object
     * represents
   public abstract List<Class<?>> parameterTypes();
   // "getParameterTypeList" if you must but you shouldn't


Your and Claes' proposal to add the index accessor adds
a more complex API point and requires more complex usage
patterns (for-loops).  In short it's very 90's.  Using a List instead
gives interoperability with new APIs like java.util.stream.

Because of the way immutable lists are organized, the sharing
and code quality at least as good as an indexed access method,
if that was a concern.

— John

More information about the core-libs-dev mailing list