enter link description hereHow does the java compiler manage to resolve inter-class references so quickly, if you have a bunch of classes that all refer to each other and use each other's methods?
I know how C++ compilers work in this regard: each .cpp file is compiled separately, and they use those awful .h files to declare class fields/methods, so that the same set of files is re-parsed each time and/or compilers have to support pre-compiled headers.
But Java doesn't do this and there's no separation in program source of class interfaces/implementations the way Turbo Pascal separated them out.
I can see that if you have a class Foo and it refers to classes Bar, Baz, Quux that are all in a separate barbazquux.jar file, then things would be straightforward: the .jar file has already been compiled, so when Foo.java gets compiled it can just go look at the .class files in barbazquux.jar.
But if you have cyclical class references, and class Foo references class Bar which references class Foo, how does it possibly compile Foo.java without having to first compile Bar.java and then decide it has to compile Foo.java and get stuck in a loop?
What does the Java compiler do to handle inter-class references?
edit: yair points out another question with answers that vaguely mentions multipass compilers. Okay, so there are multiple passes. What exactly happens on each pass and how does Java manage to compile so quickly? Does it have to re-parse each file on each pass, or does it store the abstract syntax tree to save time, or what?