title: Why doesn't reflection work when a class returns Lambdas
body: <p>I have encountered a somewhat strange behaviour. I use annotations to mark certain classes with a particular purpose, and then I use org.reflections library to find all the classes with the particular annotation. However when a class implements a method that returns a lambda function, the reflection won't find the annotated class anymore. The signature of the class is unchanged.</p>
  
  <p>Example of annotation:</p>
  
  <pre><code>@Retention(RetentionPolicy.RUNTIME)
  public @interface MyAnnotation {
     String someValue();
  }
  </code></pre>
  
  <p>Using the annotation (EDIT - added the BaseClass):</p>
  
  <pre><code>public class BaseClass {
  
      public Consumer&lt;Integer&gt; doSomething(){ return null;}
  }
  
  
  @MyAnnotation(someValue = "a")
  public class FooBar extends BaseClass {
  
      @Override
      public Consumer&lt;Integer&gt; doSomething() {
          return null;
      }
  }
  
  
  
  @MyAnnotation(someValue = "bazbar")
  public class BarClass extends BaseClass {
  
      @Override
      public  Consumer&lt;Integer&gt; doSomething(){
          return (x) -&gt; {};
      }
  }
  </code></pre>
  
  <p>Finding the annotations</p>
  
  <pre><code>private static final Reflections reflections = new Reflections("com.mypackage");
  
  Set&lt;Class&lt;?&gt;&gt; clazzes  = reflections.getTypesAnnotatedWith(MyAnnotation.class);
  </code></pre>
  
  <p>Now - the set 'clazzes' only contains <strong>1 single class</strong>, the FooBar class. If I remove the lambda return value from the BazBar class that one too shows up, but as soon as one method in the class returns a lambda the reflection wont work.</p>
  
  <p>I'm lost, any ideas?</p>