Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10396

Can't use parameter type to select among overloaded methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.18.0
    • 2.19.0
    • camel-core
    • None
    • Ubuntu 14.04

    • Unknown

    Description

      I've noticed that the overload selection mechanism based on parameter types is not working when some parameters are assignable, in the sense of Class.isAssignableFrom(...).

      Given those methods:

      String toString(String input)
      String toString(int input)
      

      We can select both methods via bean:toString(String) or bean:toString(int)

      But given those methods:

      String toString(String input)
      String toString(Object input)
      

      bean:toString(String) end in selecting toString(Object).

      Ideally, I would expect it to select toString(String). Otherwise, unwinding an AmbiguousCallException may perhaps apply.

      Thoughts:
      I'm wondering whether ObjectHelper.isOverridingMethod(...) would be mixing overload vs override.

      Will attach a test case.

      Attachments

        1. MethodOverloadCamelTest.java
          1 kB
          Alex Dettinger

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              aldettinger Alex Dettinger
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: