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

JShell: user method fails when name matches method in Object.

XMLWordPrintable

    • generic
    • generic

      See comment (below) for clarification.

      FULL PRODUCT VERSION :
      java version "9"
      Java(TM) SE Runtime Environment (build 9+181)
      Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.15063]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      No special configuration

      A DESCRIPTION OF THE PROBLEM :
      I defined a method and when i then called it, JShell offerred another one.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Enter in the JShell:

      boolean equals(double d1, double d2) {
          return d1 == d2;
      }
      equals(.1+.2, .3)


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Method call returning false
      ACTUAL -
      jshell> equals(.1+.2, .3)
      | Error:
      | method equals in class java.lang.Object cannot be applied to given types;
      | required: java.lang.Object
      | found: double,double
      | reason: actual and formal argument lists differ in length
      | equals(.1+.2, .3)
      | ^----^


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Error:
      | method equals in class java.lang.Object cannot be applied to given types;
      | required: java.lang.Object
      | found: double,double
      | reason: actual and formal argument lists differ in length
      | equals(.1+.2, .3)
      | ^----^


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      boolean equals(double d1, double d2) {
          return d1 == d2;
      }
      equals(.1+.2, .3)

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I do not know

      -------------------------------------------------------------

      Workaround: use another method name

            rfield Robert Field (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: