title: Is dynamic overload resolution possible in Java?
body: <p>So I have a class of overloaded methods like this:</p>
  
  <pre><code>class Foo {
      public void test(Object value) {
          ...
      }
  
      public void test(String value) {
          ...
      }
  }
  </code></pre>
  
  <p>I need to pass a property value of a bean to one of these methods depending on its type, but I don't know the actual property type until the runtime. e.g.</p>
  
  <pre><code>public void run(Object bean, String propertyName) {
      Foo foo = new Foo();
      foo.test(PropertyUtils.getProperty(bean, propertyName));
  }
  </code></pre>
  
  <p>BTW, <code>PropertyUtils.getProperty()</code> is a helper method that returns a value of the specified property on a bean. <code>PropertyUtils.getProperty()</code> returns an Object, so that  <code>test(Object value)</code> will be always called and the actual property type will be ignored.</p>
  
  <p>I can figure out the propery type in the runtime, even if its value is null. Is there such a thing as dynamic casting in Java? If not, is there a way to have an overloaded method with the correct parameter type called?</p>