Consider the following two classes placed in files
./net/mydomain/core/ClassA.java and
./net/mydomain/core/ClassB.java respectively:
package net.mydomain.core;
public class ClassA
{
public static void main(String[] args) throws Exception
{
ClassB classb = new ClassB();
}
}
package net.mydomain.core;
public class ClassB
{
}
If I compile this using the 'normal' Java compiler like this:
javac ./net/mydomain/core/ClassA.java ./net/mydomain/core/ClassB.java
it works fine.
Using the GCJ command:
gcj --main=ClassA ./net/mydomain/core/ClassA.java
./net/mydomain/core/ClassB.java
produces the error:
./net/mydomain/core/ClassA.java:8: error: Type ‘ClassB’ not found in the
declaration of the local variable ‘classb’.
ClassB classb = new ClassB();
Under C++ you would use an include of the header file for ClassB and a
forward declaration to solve this, whats the solution for Java classes
under GCJ?
I should point out this is a compile-time syntax error not a linker
error. Compiling ClassB separately and then passing it the .o file wont
solve it. There needs to be some way of forward declaring ClassB inside
ClassA.java.
Thanks
Andrew