RFR: (jaxp) 8005473 : Warnings compiling jaxp
forax at univ-mlv.fr
Thu Dec 27 22:26:06 UTC 2012
On 12/27/2012 10:41 PM, Chris Hegarty wrote:
>>> Method method = clazz.getMethod(DOM_LEVEL3_METHOD);
>>> is equivalent to
>>> Method method = clazz.getMethod(DOM_LEVEL3_METHOD, new Class<?>);
>>> so you allocate an empty array each time you call getMethod.
>>> A better patch is to cast null to Class<?> (or Object for invoke)
>>> Method method = clazz.getMethod(DOM_LEVEL3_METHOD, (Class<?>)null);
> Is this something that the compiler could do? Or is this
> "inefficiency" baked into spec, or serve another purpose?
The compiler has to create an empty array if there is not enough
parameter from the spec (JLS7 22.214.171.124), but Class.getMethod() or
Method.invoke() are special because they specified that null is a valid
argument equivalent to an empty array.
More information about the core-libs-dev