cons-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: javac issues


From: akolarik
Subject: RE: javac issues
Date: Tue, 18 Dec 2001 09:56:40 -0500

There's been periodic discussion of this on the list, in case you want to hunt around for it in the archive.  Unfortunately there doesn't seem to be any search functionality there, and I can't remember when the discussions took place :-( 

However here's something from the FAQ.
 -- Tony K.

9.3. Does Cons support Java?
Using Cons to build Java projects is possible, but not straightforward. Java has a number of characteristics that don't fit well with the Cons (and Make) model of creating a dependency tree to determine what needs rebuilding:

        --  Java dependency analysis is more complex than the simple
            #include scanning of C and C++, arising from the classes
            used by the code in addition to the import statements.
        --  As a result of the class dependencies present, the Java
            compiler may create or update multiple output class files
            and directories.
        --  Java may automatically rebuild class files, even if not
            explicitly given as an argument to the compiler.
        --  Java may read possibly obsolete class files from previous
            compiler runs.
     
From the point of view of an outside build tool, the Java compiler is essentially unpredictable, creating or updating whatever files it decides need it. This makes it extremely difficult for a build tool such as Cons to decide what needs updating, or has been updated, by Java.

One approach that has been suggested would extend cons to scan the output of the Java -depend -verbose command to build dependency lists. Some additional mechanism would need to be invented to store Cons signatures on classes that are stored in archives (jar or zip files). This solution does not exist today.

An alternative approach that is already in use by Jochen Schwarze (address@hidden) is to use an intermediate script that passes a list of Java files to the java compiler, and puts the output class files in a new temporary directory. The script then calls jar to pack the newly-generated class files into a single jar file, essentially sidestepping the dependency issue. A second script is then used to merge the multiple jar files generated by the first script into a single file. This approach fits Cons more readily because the first script acts somewhat like a meta-compiler, creating a single object from Java source files, and the second acts like a linker, creating a single executable from multiple "objects."

The advantage to this approach is that it makes the builds very reliable, because there's no chance that an obsolete but unremoved class file will be incorporated into a build by the javac compiler. The disadvantage, however, is that there's no way to incrementally update a portion of a jar file, since from Cons' point of view, each is created atomically by a single call to the "compile" script.

Jochen has offered in the past to make his scripts available, but he is very busy, so be patient and courteous if you ask him for them.


> -----Original Message-----
> From: Michael Cook [mailto:address@hidden]
> Sent: Monday, December 17, 2001 11:26 AM
> To: address@hidden
> Subject: javac issues
>
>
> has anyone any experience using cons with javac?  javac has
> considerable startup overhead.  so, invoking javac once with 100
> *.java files is much (!) quicker than invoking javac 100 times once
> per file.
>
> if only some of the 100 *.java files need to be re-compiled, ideally
> cons could figure out which need to be recompiled and then invoke
> javac only once and passing only that subset of the files.
>
> thoughts?
>
> m.
>
> _______________________________________________
> address@hidden
> http://mail.gnu.org/mailman/listinfo/cons-discuss
> Cons URL: http://www.dsmit.com/cons/
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]