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

Christoph Dreis christoph.dreis at freenet.de
Thu Nov 2 22:00:18 UTC 2017

Hey John,

>> Could you elaborate, please?

> Sure.  It's really quite simple:  Replace the old mutable array
> with a modern immutable list.
> ....
> 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.

Thanks for the clarification. Actually the more important concern was to get rid of unnecessary allocations that the cloning inside Executable.getParameterTypes() is producing. As Claes mentioned experience and experiments show that JIT's escaping mechanisms fail from time to time on this one. And if you ask me it is not good practice to rely on the compiler optimizations anyhow, but that's maybe just me.

I do like your proposal nonetheless as an additional improvement, but I think it won't achieve the allocation-free part I was aiming for. Correct me if I'm wrong, please.


More information about the core-libs-dev mailing list