title: Java: How to find if a method is overridden from base class?
body: <p>How to find out if a method is overridden by child classes?</p>
  
  <p>For example,</p>
  
  <pre><code>public class Test {
  
  static public class B {
      public String m() {return "From B";};
  }
  
  static public class B1 extends B {
  
  }
  
  static public class B2 extends B {
      public String m() {return "from B2";};
  }
  
  /**
   * @param args
   * @throws FileNotFoundException 
   */
  public static void main(String[] args)  {
  
      B b1 = new B1();
      System.out.println("b1 = " + b1.m());
      B b2 = new B2();
      System.out.println("b1 = " + b2.m());
  }
  
  }
  </code></pre>
  
  <p>Given an instance of B, how do I know if any derived classes have overridden method m() like B2?</p>
  
  <p>Update: My question wasn't clear. Actually, I was trying to ask if this is possible without resorting to reflection. This check is done in a tight loop and it's used in a performance hack to save a few CPU cycles.</p>