4 Replies Latest reply: Sep 2, 2009 2:13 AM by jwenting RSS

    Compiling all references of an interface

    843810
      Hi all,

      I want to control the java compiler, so that it not only compiles an interface, but all uses of this interface. I do have two packages, one where the interface is located and another where the implementation class is located. When I use the following commandline for javac, only the interface is compiled:

      javac -sourcepath src/main/java -d target/classes src/main/java/test/compiler/api/Interface.java

      The implementation class is located under test/compiler/impl/Implementation.java. I am looking for a way to tell javac to compile the implementation as well without explicitly itemizing the implementation class in the compile list.

      Thanks in advance,

      Landrus
        • 1. Re: Compiling all references of an interface
          EJP
          There isn't such an operation within javac.

          Use ANT.

          Or compile the entire implementation package. It only takes a few seconds.
          • 2. Re: Compiling all references of an interface
            843810
            :)

            I know there is ant and maven and IDEs and such things. But there is a reason why I dont want to compile all sources. In the project I am working on we have round about 80k source files. We do not want to compile everything just because a few files changed :)

            I am working on a solution that just does enough to be correct. Like compile only necessary files, use jar -u instead of rebuilding the whole jar, etc. The thing is that javac and ecj only automatically compile known references like supertypes and such, but not usage reference in the (very) simple example I have given.
            • 3. Re: Compiling all references of an interface
              jschellSomeoneStoleMyAlias
              Landrus_de wrote:
              The implementation class is located under test/compiler/impl/Implementation.java. I am looking for a way to tell javac to compile the implementation as well without explicitly itemizing the implementation class in the compile list.
              And how do you think that javac would know that without at a minimum searching your 80k files?
              • 4. Re: Compiling all references of an interface
                jwenting
                jschell wrote:
                Landrus_de wrote:
                The implementation class is located under test/compiler/impl/Implementation.java. I am looking for a way to tell javac to compile the implementation as well without explicitly itemizing the implementation class in the compile list.
                And how do you think that javac would know that without at a minimum searching your 80k files?
                And every computer in the multiverse? That project may not be the only one containing references to those interfaces :)