title: IllegalAccessError while working on inheritance - Why?
body: <p>I found <a href="https://bugs.openjdk.java.net/browse/JDK-8021581" rel="nofollow noreferrer">this JDK bug</a> and want to understand why it happens.</p>
  
  <p>The scenario (taken from <a href="https://bugs.openjdk.java.net/browse/JDK-8021581" rel="nofollow noreferrer">the bug report</a>) is very simple: a <code>class</code> declaring a <code>private</code> method, and an <code>interface</code> declaring a <code>public</code> method with the same signature. It compiles without error.</p>
  
  <p>However, when I run this code I am getting <code>IllegalAccessError</code></p>
  
  <pre><code>interface I {
      public void m();
  }
  
  class A {
      private void m() {
          System.out.println("Inside Class A");
      }
  
  }
  
  abstract class B extends A implements I {
  }
  
  class C extends B {
      public void m() {
          System.out.println("Inside Class C");
      }
  }
  
  public class Test {
      public static void main(String... args) {
          B b = new C();
          b.m();
      }
  }
  </code></pre>
  
  <p>Please help me understand why this error is there as <strong>my code is compiling fine</strong>.</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalAccessError:  
  tried to access method A.m()V from class Test
      at Test.main(Test.java:25)
  </code></pre>