This isn't really a circular dependency. See
JLS 8.1.4:
A class C directly depends on a type T if T is mentioned in the extends or implements clause of C either as a superclass or superinterface, or as a qualifier of a superclass or superinterface name. A class C depends on a reference type T if any of the following conditions hold:
C directly depends on T.C directly depends on an interface I that depends (§9.1.3) on T.C directly depends on a class D that depends on T (using this definition recursively).
It is a compile-time error if a class depends on itself.
For example:
class Point extends ColoredPoint { int x, y; }
class ColoredPoint extends Point { int color; }
causes a compile-time error.
If circularly declared classes are detected at run time, as classes are loaded (§12.2), then a ClassCircularityError is thrown.
The key part of this, for our purposes here, is that dependency is defined in terms of types that appear in an extends or implements clause. It doesn't matter if a class appears elsewhere, such as the type of a field, or method or constructor calls. So applying this definition to the code above, class B depends on A (because it extends A). Class A does
not depend on class B.
As a practical matter, how does the compiler achieve this? Well, compilation can be a multi-pass thing. It's not necessary to completely compile one class before even looking at another class. Probably the compiler looks at extends clauses in both classes first, and figures out that B depends on A. Then it looks at all the method signatures in each and remembers them. Then it compiles A. When it sees the reference to B, that's not a problem - the compiler knows there is a class named B, and knows what methods you can call on a B, even though those methods haven't been fully compiled yet. It just inserts code that says to go find class B and execute certain methods in it. It doesn't need to know exactly what those methods do. This allows it to complete the compilation of A. Once done with that, it can compile B as well, no problem.