Search code examples
compilationjavajavac

How to Prevent Dependency checking in java compiler


I am trying to prevent dependency checking in java compiler, I use command line compilation,is there any way to tell javac compiler not to check dependency while compiling a java file ?


Solution

  • ... is there any way to tell javac compiler not to check dependencies while compiling a java file ?

    The simple answer is No.

    Suppose you have some class A that wants to call some method m defined by class B. In order to successfully compile A, the compiler needs to know that B is a real class, that it defines the method m, that it has the expected number and type of arguments, what checked exceptions it throws, and what type of value it returns. Without this information about B, the compiler cannot compile A.

    And this propagates to the project level. If a class in project P depends on a class in project Q, the compiler must have that class (at least) in order to compile the class in P.

    In short, no such compiler option exists, and it is hard to see how it could be implemented it it did.