Not the best error message.

Bryce McKinlay
Sun May 6 22:22:00 GMT 2001

Mo DeJong wrote:

> Gcj is giving me this really strange error
> message.

> Any comments on what this sort of error *should* print?

I guess the compilers are getting confused because you have "Crash" declared
in package "foo" and "Crash_Test" in the empty package, yet they are both in
the same directory?

So in this case, the ideal error message should be something like "class
"Crash" was declared in package "foo" but was not found in a directory
called "foo" relative to the base directory for compilation". However, I'm
not sure that a compiler can legally give that error (maybe a warning?),
without checking that parent directory heirarchy is correct for the package
declaration, and that would probibly differ from javac's behaviour.

The "duplicate class" errors are strange but probibly a feature of the way
classes are resolved - the compiler reads once and sees that the
class is called foo.Crash, then reads it again after seeing that there is no
class called "Crash" loaded and that there is a file called,
since you specified on the command line as well. The "type not
found" errors are certainly correct (just not as verbose as they could be).

FWIW, if they are put in the correct package, javac reports the correct
error (Crash_Inner not visible to Crash because it has default access),
while gcj incorrectly compiles the code without an error.


  [ bryce ]

More information about the Java mailing list