title: Why do I get a BootstrapMethodError when trying to call a super class's protected method using method reference from an inner class?
body: <p>In Java 8, given a super class <code>Super</code> in package <code>a</code> and a sub class <code>Sub</code> in package <code>b</code>, who has an inner class <code>SubInner</code>:</p>
  
  <pre class="lang-java prettyprint-override"><code>// Super.java
  package a;
  
  public abstract class Super {
     private long value;
     protected final void setValue(long value) {
        this.value = value;
     }
  }
  
  //Sub.java
  package b;
  
  public class Sub extends Super {
    public void foo() {
      new SubInner().foo();
    }
    private class SubInner {
      void foo() {
        Optional.of(1L).ifPresent(Sub.this::setValue); // Will throw IllegalAccessError at runtime.
        Optional.of(1L).ifPresent(t -&gt; setValue(t)); // However, lambda works.
        setValue(1L); // also works.
      }
    }
  }
  </code></pre>
  
  <p>My question is, why method reference fails to work in this case while normal method call have access to super class method <code>setValue</code>?</p>
  
  <p>Plus, if I try to do <code>Sub.super::setValue</code>, the code doesn't compile and the error seems to be in-line with the runtime error: <code>setValue</code> has protected access in <code>a.Super</code>.</p>
  
  <pre><code>Exception in thread "main" java.lang.BootstrapMethodError: java.lang.IllegalAccessError: tried to access method a.Super.setValue(J)V from class b.Sub$SubInner
      at b.Sub$SubInner.foo(Sub.java:14)
      at b.Sub.foo(Sub.java:10)
      at b.Sub.main(Sub.java:22)
  Caused by: java.lang.IllegalAccessError: tried to access method a.Super.setValue(J)V from class b.Sub$SubInner
      at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
      at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:975)
      at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1000)
      at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1394)
      at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1750)
      at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477)
      ... 3 more
  </code></pre>