Not the best error message.

Mo DeJong mdejong@cygnus.com
Sun May 6 18:57:00 GMT 2001


Hi all.

Gcj is giving me this really strange error
message. I was able to figure out what the
problem was, but I think gcj should be
touched up a bit so that a better error
message is provided. Here is the test case.

% cat Crash.java
package foo;

public class Crash {
    static class Crash_Inner {}
}

% cat Crash_Test.java 
//import foo.Crash;

class Crash_Test {
    void foo() {
        Crash.Crash_Inner i = null;
    }
}

% gcj -C Crash.java Crash_Test.java
./Crash.java:3: Class `foo.Crash' already defined in Crash.java:3.
   public class Crash {
                ^
./Crash.java:4: confused by earlier errors, bailing out


The problem can be fixed by uncommenting the import statement
in the second file. Of course, my real question is ...
what should this error message be?


The javac error message is a little better, but it
also goes on about a duplicate class.

% javac Crash.java Crash_Test.java
./Crash.java:3: duplicate class: foo.Crash
public class Crash {
       ^
Crash_Test.java:5: cannot resolve symbol
symbol  : class Crash_Inner  
location: class Crash
        Crash.Crash_Inner i = null;
             ^
2 errors


The error message printed by Jikes is not very
clear either:

% jikes Crash.java Crash_Test.java

Found 2 semantic errors compiling "Crash_Test.java":

     5.         Crash.Crash_Inner i = null;
                <--->
*** Error: Type Crash was not found.


     5.         Crash.Crash_Inner i = null;
                      <--------->
*** Error: Type Crash$Crash_Inner was not found.

Found 1 semantic error compiling "Crash.java":

     3. public class Crash {
                     <--->
*** Error: Duplicate declaration of type "Crash". The other occurrence is 
at location Crash.java:3.


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

Mo DeJong
Red Hat Inc



More information about the Java mailing list