How does javac automatically compile dependencies of a class

前端 未结 3 1907
走了就别回头了
走了就别回头了 2020-12-29 08:55

Given the following directory structure:

/top
   |--- wrk
          |--- pkg
                  |--- A.java
                  |--- B.java

As

3条回答
  •  粉色の甜心
    2020-12-29 09:14

    The compiler has to either find and successfully compile a source for B, or find a .class for B even if it's just an import. As opposed to loading, which is done dynamically.

    Look in your output directory and you'll see that B has been compiled as well. It will be compiled even if in a different package, but you'll have to make it public to reference it from A.

提交回复
热议问题