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

Christoph Dreis christoph.dreis at freenet.de
Mon Oct 23 11:30:51 UTC 2017


Hey,

> > >      public Class<?> getParameterType(int index) {
> > >          if (index < 0 || index > getParameterCount()) {
> > >              throw new IndexOutOfBoundsException("No parameter found 
> > > on index " + index);
> > >          }

> > I don't think we need the explicit range check here.

> I thought about that, but decided against the specific
> ArrayIndexOutOfBoundsException which would be thrown if we omit the
> explicit check. My reasoning behind that was that the API should not expose
> the fact that it's working with an array underneath. I have no strong feelings
> against your comment, though. I'd be fine with both solutions.

On a second thought, people might expect the ArrayIndexOutOfBoundsException.

And it would behave the same way as getParameterTypes()[index] does currently. So I'd probably in favor of omitting it as you suggested.

Cheers,
Christoph 



More information about the core-libs-dev mailing list