public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Forward declaration of classes needed when using GCJ?
@ 2008-02-10 17:14 Andrew W
  2008-02-11 17:50 ` David Daney
  0 siblings, 1 reply; 17+ messages in thread
From: Andrew W @ 2008-02-10 17:14 UTC (permalink / raw)
  To: gcc-help

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





^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2008-02-18  4:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-10 17:14 Forward declaration of classes needed when using GCJ? Andrew W
2008-02-11 17:50 ` David Daney
     [not found]   ` <47B098D1.1050200@iee.org>
2008-02-11 18:58     ` David Daney
2008-02-11 21:56   ` Andrew W
2008-02-11 22:37     ` David Daney
2008-02-12 16:02       ` Andrew W
2008-02-12 17:48         ` Andrew Haley
2008-02-15 18:24         ` Andrew W
2008-02-15 18:31           ` Building cross compiler for x86_64 Frank W. Miller
2008-02-16  0:00             ` Brian Dessent
2008-02-16  0:14               ` Frank W. Miller
2008-02-16  0:33                 ` Brian Dessent
2008-02-16 20:06             ` Frank W. Miller
2008-02-17  2:52               ` Brian Dessent
2008-02-17  2:55                 ` NightStrike
2008-02-18  4:39                   ` Frank W. Miller
2008-02-15 19:51           ` Forward declaration of classes needed when using GCJ? Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).