Annotations containing lambda expressions in Java 8
<p>I am experimenting with static fields in annotations and I am stumbling upon something I do not understand.</p>

<p>I use the following code:</p>

<pre><code>@a
public class myAnnotMinimal {
    public static void main(String[] args) {
        System.out.println(myAnnotMinimal.class.getAnnotations().length);
    }
}

@Retention(RetentionPolicy.RUNTIME)
@interface a {
    Consumer&lt;Integer&gt; f1 = a -&gt; {return;}; // -&gt; 0
    //Consumer&lt;Integer&gt; f2 = new B();  //-&gt; 1
    //Consumer&lt;Integer&gt; f3 = C::eat; //-&gt; 1
    //int f4 = 5; //-&gt;1
    //Supplier&lt;Integer&gt; f5 = ()-&gt;5; //-&gt;1
}

class B implements Consumer&lt;Integer&gt; {
    @Override
    public void accept(Integer t) {
    }
}

class C{
    public static void eat(Integer t){
    }
}
</code></pre>

<p>Now, when running this I would expect '1' to be printed, however, the output I get is '0'. When I remove the f1 field and uncomment the other (f2-f5) fields the output is '1'. To me this pretty much looks like a bug. Is there something I am missing? I use jdk1.8.0_66 on linux.</p>

<p>Since this looks like a bug in the JDK I filed a bug report. By now the bug report has been accepted. See <a href="http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8147585" rel="noreferrer">http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8147585</a> .</p>