title: Overriding default accessor method across different classloaders breaks polymorphism
body: <p>I come across to a strange behavior while trying to override a method with <em>default accessor</em> (ex: <code>void run()</code>).
  According to Java spec, a class can use or override default members of base class if classes belongs to the same package.
  Everything works correctly while all classes loaded from the same classloader.
  But if I try to load a subclass from <em>separate</em> classloader then polymorphism don't work.</p>
  
  <p>Here is sample:</p>
  
  <p>App.java:</p>
  
  <pre><code>import java.net.*;
  import java.lang.reflect.Method;
  
  public class App {
      public static class Base {
          void run() {
              System.out.println("error");
          }
      }
      public static class Inside extends Base {
          @Override
          void run() {
              System.out.println("ok. inside");
          }
      }
      public static void main(String[] args) throws Exception {
          {
              Base p = (Base) Class.forName(Inside.class.getName()).newInstance();
              System.out.println(p.getClass());
              p.run();
          } {
              // path to Outside.class
              URL[] url = { new URL("file:/home/mart/workspace6/test2/bin/") };
              URLClassLoader ucl = URLClassLoader.newInstance(url);
              final Base p = (Base) ucl.loadClass("Outside").newInstance();
              System.out.println(p.getClass());
              p.run();
              // try reflection
              Method m = p.getClass().getDeclaredMethod("run");
              m.setAccessible(true);
              m.invoke(p);
          }
      }
  }
  </code></pre>
  
  <p>Outside.java: should be in separate folder. otherwise classloader will be the same</p>
  
  <pre><code>public class Outside extends App.Base {
      @Override
      void run() {
          System.out.println("ok. outside");
      }
  }
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>class App$Inside
  ok. inside
  class Outside
  error
  ok. outside
  </code></pre>
  
  <p>So then I call <code>Outside#run()</code> I got <code>Base#run()</code> ("error" in output). Reflections works correctly.</p>
  
  <p>Whats wrong? Or is it expected behavior?
  Can I go around this problem somehow?</p>