JDK-8202689 : Issue on Method.invoke when using wrong number of arguments
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 8,10,11
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: x86_64
  • Submitted: 2018-05-04
  • Updated: 2018-05-07
  • Resolved: 2018-05-07
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Picked up _JAVA_OPTIONS:   -Dawt.useSystemAAFontSettings=gasp
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

A DESCRIPTION OF THE PROBLEM :
The following program presents a null exception message after invoking 17 times a method with wrong number of arguments.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the program
2. Run it using Oracle HotSpot java

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Always print "wrong number of arguments" message.
ACTUAL -
wrong number of arguments (x16)
null

---------- BEGIN SOURCE ----------
import java.lang.reflect.Method;
public class A {
    public static void main(String[] args) throws NoSuchMethodException {
        A a = new A();
        for (int i = 0; i < 17; i++) {
            Method method = A.class.getMethod("wait", long.class);
            try {
                method.invoke(a, 0, 1);
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }
    }
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
This is the generated method accessor, it is generated and used once the inflation threshold (15) is exceeded. The generated code should throw IAE with a more useful exception message. This is known issue JDK-8202012
07-05-2018