PCH for java - is this a good idea?

Per Bothner per@bothner.com
Wed Feb 21 09:51:00 GMT 2001

Martin Kahlert <martin.kahlert@infineon.com> writes:

> So i assume, it reads the file goodstuff.java if it comes around something like
> goodstuff gs = new goodstuff();
> gs.do_something();

Or it can read goodstuff.class.

> So if i have a big number of files and goodstuff is some kind of a really
> large support class, the compilation of every file has to read goodstuff.java
> (if gcj is called from a makefile for example).

Yes (or read goodstuff in some other way).

> This will last a long time.

It could, but I'm not sure it's that bad.

One mitigation is a patch (which I haven't checked in yet) to compile
a list of .java files in one run of the compiler.  I.e. if you say:
        gcj -o foo-package.o -c *.java
all of the *.java packages will be compiled together, and each will
only be read once.  So if you have a package with (say) 20 files,
and each package on average references (say) 5 other class in the same
package, compiling them separately would require reading a .java
files 20*(1+5)=60 times.  Compiling them all together would require
reading each Java files only once, reducing parse time to a third.

> So would it be a good idea, to build some kind of a compressed header file
> for scanned .java files? Perhaps the PCH support of C/C++ (which seems to
> be worked on) could be reused?

We have a pre-compiled header file format for Java, and gcj
already handles it - it is called a .class file.
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

More information about the Java mailing list