Replace method.getParameterCount() for java 5 compatible method (#10215)

java.lang.reflect.Method.getParameterCount() exists since java 8 only.

Change-Id: Ie665898912fdcf2dab2ff0bc3bb3a64d30b6fea8