[antlr-interest] GCJ

Pete Forman pete.forman at westerngeco.com
Tue Jul 15 00:54:44 PDT 2003


At 2003-07-15 10:36 +1000, Robert Colquhoun wrote:
>At 02:01 AM 15/07/2003, Pete Forman wrote:
> >At 2003-07-14 23:06 +1000, Robert Colquhoun wrote:
> > >At 11:28 AM 14/07/2003 +0200, Ric Klaren wrote:
> > > >On Mon, Jul 14, 2003 at 12:19:32PM +1000, Robert Colquhoun wrote:
> > > > > Also java source files are kind of different from C/C++ there are no
> > > > > includes(making for a much faster compile) and dependencies can 
> be very
> >
> >Includes are done with the import statement.
>
>But that is not like a C/C++ #include which pulls in another file which the
>compiler has to parse.  Java 'package' and 'import' is a bit like C++
>'namespace' and the 'using' directive.

True, I had simplified the matter.

>In bigger C/C++ it is not unusual for the compiler to have to pull in >
>10,000 lines of includes every time it parses a single source file.  This
>takes time slowing the build perhaps more time than compiling the actual
>source files themselves.  Some compilers do precompiled headers to try and
>mitigate this.

Loosely speaking again, Java "headers" are precompiled.  A reference to
a class or interface will read in its .class file.  If that file does
not exist or is out of date wrt its source then it is compiled (once).

> > >As soon as you make a java change you need to recalculate the dependency
> > >tree using some tool.  That's not happening with the configure/make stuff
> > >at the moment there is only the original dependencies.
> >
> >The Java compiler handles dependencies internally.  If you compile
> >just one file then all the .java files it references are compiled as
> >well (including indirect references) if they have no .class.  It is
> >often enough just to name those files with a main() on javac's command
> >line.
>
>Can get in trouble though if you compile one file that has a dependency
>which already has a class file available....it doesnt check to see if the
>dependency source is out of date with respect to its class file unless the
>dependency itself is also specified on the command line.

Not true.  Here's a simple example of it working.

a/A.java:
package a;
import b.B;
class A {
   private B myB;
   public A() {
     myB = new B();
   }
}

b/B.java:
package b;
public class B {
   private int foo = 0;
   public B() {
     foo = 1;
   }
}

command line:
javac -classpath . a/A.java

results:
A.class is always generated.
B.class is generated if B.java is newer than it.

There is no explicit reference to B on the command line.

> >The traditional way of compiling C/C++ one file at a time under make
> >or similar is not well suited to Java.  It is best if javac can be
> >invoked once only during a build.
>
>Yes for sure - the javac compiler has to start up a jvm which is expensive,
>some relief can be gained by using a compiler like jikes if you like 
>makefiles.

My point is that all the work that is traditionally done by make
depend is done in javac.  Avoiding multiple JVM startups is a bonus.

-- 
Pete Forman                -./\.-  Disclaimer: This post is originated
WesternGeco                  -./\.-   by myself and does not represent
pete.forman at westerngeco.com    -./\.-   opinion of Schlumberger, Baker
http://petef.port5.com           -./\.-   Hughes or their divisions.


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list