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

java.beans.Statement throws NoSuchMethodException when method has overloaded primitive arguments

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_144"
      Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
      Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)


      A DESCRIPTION OF THE PROBLEM :
      When a method is overloaded with both primitive & non-primitive types, attempting to invoke that method using either java.beans.Statement or java.beans.Expression results in a java.lang.NoSuchMethodException.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No exception should be thrown
      ACTUAL -
      java.lang.NoSuchMethodException: ExpressionBug.primitiveOverload(Integer);

      at java.beans.Statement.invokeInternal(Statement.java:313)
      at java.beans.Statement.access$000(Statement.java:58)
      at java.beans.Statement$2.run(Statement.java:185)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.beans.Statement.invoke(Statement.java:182)
      at java.beans.Statement.execute(Statement.java:173)
      ...

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import org.junit.Test;

      import java.beans.Statement;

      public class ExpressionBug {

          public void primitiveOverload(int arg) {}
          public void primitiveOverload(Integer arg) {}
          public void overload(Double dbl) {}
          public void overload(Number number) {}

          @Test
          public void fails() throws Exception {
              new Statement(this, "primitiveOverload", new Object[] { 10 }).execute();
          }

          @Test
          public void passes() throws Exception {
              new Statement(this, "overload", new Object[] { 10d }).execute();
          }
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: