enter a description of the link here How does the java compiler manage to quickly resolve interclass links if you have a bunch of classes that all relate to each other and use other methods?
I know how C ++ compilers work in this regard: each .cpp file is compiled separately, and they use these terrible .h files to declare class fields / methods, so the same set of files and / or compilers must support precompiled headers.
But Java does not, and there is no separation in the software source of the class interfaces / implementations, as Turbo Pascal disabled.
I see that if you have the Foo class and it belongs to the Bar, Baz, Quux classes, which are in a separate barbazquux.jar file, then everything will be simple: the .jar file is already compiled, so when Foo.java is compiled, it can just look at the .class files in barbazquux.jar.
But if you have circular references to classes, and the Foo class refers to the Bar class, which refers to the Foo class, how can it compile Foo.java without having to compile Bar.java first, and then decide that it should compile Foo.java and get stuck in the loop?
What does the Java compiler do to handle references between classes?
edit: yair points out another question with answers vaguely mentioned by multipass compilers. Good, so there are a few passes. What exactly happens on each pass and how does Java manage to compile so fast? Do I need to sort out each file in each pass or store an abstract syntax tree to save time or what?
source share