Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8202689

Issue on Method.invoke when using wrong number of arguments

XMLWordPrintable

      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


            fmatte Fairoz Matte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: