title: When is CGLIB proxy used by Spring AOP?
body: <p>I was reading some articles about Spring AOP and encountered this:</p>
  
  <blockquote>
    <p>AOP proxy: the object created by AOP to implement the aspect
    contracts. In Spring, proxy objects can be JDK dynamic proxies or
    CGLIB proxies. By default, the proxy objects will be JDK dynamic
    proxies, and the object being proxied must implement an interface,
    that will also be implemented by the proxy object. But a library like
    CGLIB can be used to create proxies by subclassing too, so an
    interface is not needed.</p>
  </blockquote>
  
  <p>Could you look at the following structure and imagine that we want to advise <code>bar()</code> method.</p>
  
  <pre><code>public interface Foo {
      void foo();
  }
  
  public class FooImpl implements Foo {
  
      @Override
      public void foo() {
          System.out.println("");
      }
  
      public void bar() {
          System.out.println("");
      }
  
  }
  </code></pre>
  
  <p>Does it mean that in this case CGLIB proxy will be used?
  Since JDK dynamic proxy isn't able to implement any interface in order to override <code>bar()</code> method.</p>