This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Multiple Java Source Files - Combine Inputs By Default


On Mon, 21 Jun 2004 11:38:05 +0100, Andrew Haley <aph@redhat.com> wrote:
> 
> Ranjit Mathew writes:
>  >
>  > If I use "-o" with "-c" like:
>  >
>  >   gcj -c -o snafu foo.java bar.java baz.java
>  >
>  > my understanding is that GCC will create file "snafu"
>  > that contains *one* of what would have been "foo.o",
>  > "bar.o" and "baz.o".
> 
> That is not my understanding.

Silly me - I ought to have checked it first. :-(

While "gcc" doesn't let me specify "-o"
with "-S" or "-c" if multiple input files are 
present, "gcj" does. And "gcj" creates 
something that is neither of "foo.o" or "bar.o".
I'm guessing that this file then is an object
file containing code from *both* "foo.java" and
"bar.java".

Curiouser and curiouser...


>  > Simply put, what I'm saying is that the effect of:
>  >
>  >   gcj --main=Foo Foo.java Bar.java
>  >
>  > and
>  >
>  >   gcj -o snafu --main=Foo Foo.java Bar.java
>  >
>  > can possibly be different currently (apart from "a.out" v/s
>  > "snafu" as the output file), and inconsistent even, leading to
>  > the user getting confused.
> 
> That sounds like a bug.  The -o argument should only affect the output
> of a compiler invocation with -c or -S.

But from the code snippet I posted earlier from
"jvspec.c", it actually affects the "compiling multiple
files at once" bit of jc1.

What happens is that java_parse_file() in jcf-parse.c
first iterates through all source files calling parse_source_file_1()
on them. It then calls parse_source_file_2() on each file
and finally parse_source_file_3() on each file (separate loops).

On the other hand, read_class() in jcf-parse calls
parse_source_file_1/2/3() when it reads a source file.

Since parse_source_file_2() is what effects resolution,
completion, etc. in a parsed class, class "Foo"'s view
of class "Bar" can change quite a bit depending on
whether "Bar" is seen via the command line ("combine
inputs") or discovered via read_class().

Ranjit.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]