title: Usage, Javac translation and runtime behavior of local classes
body: <p>I occasionally use an implementation pattern (or idiom) where concrete implementations of an interface are encapsulated as a local class within factory methods and I'm interested in whether this is a bad or valid practice? How exactly does javac handle local classes? Are local classes lifted to top-level? IntelliJ unfortunately can't show me any bytecode for this. Furthermore I would be interested in the dynamics. Is there any negative impact for the runtime machinery (like dynamic class hierarchy analysis) and JIT compilation?</p>
  <pre><code>interface Transformer&lt;A, B&gt; extends Function&lt;Iterable&lt;A&gt;, Iterable&lt;B&gt;&gt; {
  
      @Override
      Iterable&lt;B&gt; apply(Iterable&lt;A&gt; itr);
  
      /// FACTORIES.
  
      /** Creates an transformer according to approach X. */
      static &lt;A, B&gt; Transformer&lt;A, B&gt; makeX(/* X specific params */) {
          final class TX implements Transformer&lt;A, B&gt; {
              @Override
              public Iterable&lt;B&gt; apply(Iterable&lt;A&gt; itr) {
                  // ... X-style impl.
              }
          }
          return new TX();
      }
  
      /** Creates an transformer according to approach Y. */
      static &lt;A, B&gt; Transformer&lt;A, B&gt; makeY(/* Y specific params */) {
          final class TY implements Transformer&lt;A, B&gt; {
              @Override
              public Iterable&lt;B&gt; apply(Iterable&lt;A&gt; itr) {
                  // ... Y-style impl.
              }
          }
          return new TY();
      }
  }
  </code></pre>