This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
RE: libgcj/2737: User-defined thrown exception is not found
- To: "'Jeff Sturm'" <jsturm at one-point dot com>, jddahl <jddahl at micron dot com>
- Subject: RE: libgcj/2737: User-defined thrown exception is not found
- From: jddahl <jddahl at micron dot com>
- Date: Thu, 21 Jun 2001 09:49:57 -0600
- Cc: "'tromey at redhat dot com'" <tromey at redhat dot com>, gcc-bugs at gcc dot gnu dot org
> For the compiler to find a class B needed by class A, at least one of
> the following must be true:
>
> 1) A is an inner class of B (or vice versa)
> 2) B.java is named on the gcj command line along with A.java
> 3) B.class is available in the class path (or a .jar
> containing B.class)
> 4) B.java is available on the class path
>
> It is sometimes helpful to compile in two phases, especially
> for larger
> projects: .java -> .class followed by .java -> .o. This is how libgcj
> builds itself. The main advantage of having class files
> available is that
> gcj can parse them much faster than source files.
Why do you compile ".java -> .class" if you then compile straight from
".java -> .o"?
And then how do you compile all the .o's into an executable without getting
things multiply defined?
I have an exception class that is thrown from class A. To test that class A
works properly, I created a Test.java that instantiates class A. I have
compiled all three down to .o's with the following commands:
EXCEPTION:
gcj --encoding=UTF-8 -c -shared -o
/u/jddahl/java/objects_solaris/test/core/InitializationException.o
/u/jddahl/java/sources/test/core/InitializationException.java
CLASS A:
gcj --encoding=UTF-8 -c -o
/u/jddahl/java/objects_solaris/test/core/LotNumber.o
/u/jddahl/java/sources/test/core/InitializationException.java
/u/jddahl/java/sources/test/core/LotNumber.java
TEST:
gcj --encoding=UTF-8 -c -I/u/jddahl/java/sources -o Test.o
/u/jddahl/java/sources/test/core/InitializationException.java
/u/jddahl/java/sources/test/core/LotNumber.java Test.java
But when I compile with this command:
gcj -o test Test.o /u/jddahl/java/objects_solaris/test/core/LotNumber.o
/u/jddahl/java/objects_solaris/test/core/InitializationException.o
I get the following:
ld: fatal: symbol `test::core::InitializationException::class$ ' is
multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `test::core::LotNumber::LotNumber(java::lang::String*)' is
multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol
`test::core::InitializationException::InitializationException(java::lang::St
ring*)' is multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `test::core::LotNumber::getTravelerID() ' is multiply
defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `vtable for test::core::LotNumber' is multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `test::core::LotNumber::pathFormat(int)' is multiply
defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `test::core::LotNumber::fileFormat() ' is multiply
defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `vtable for test::core::InitializationException' is
multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `test::core::LotNumber::getTravelerExt() ' is multiply
defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `test::core::LotNumber::toString() ' is multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `test::core::LotNumber::pathFormat(java::lang::String*) '
is multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `test::core::LotNumber::slashFormat() ' is multiply
defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `test::core::LotNumber::class$ ' is multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol
`test::core::InitializationException::InitializationException()' is multiply
defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/LotNumber.o);
ld: fatal: symbol `test::core::InitializationException::class$ ' is
multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/InitializationException.o);
ld: fatal: symbol
`test::core::InitializationException::InitializationException(java::lang::St
ring*)' is multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/InitializationException.o);
ld: fatal: symbol `vtable for test::core::InitializationException' is
multiply defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/InitializationException.o);
ld: fatal: symbol
`test::core::InitializationException::InitializationException()' is multiply
defined:
(file Test.o and file
/u/jddahl/java/objects_solaris/test/core/InitializationException.o);
ld: fatal: File processing errors. No output written to test
collect2: ld returned 1 exit status
Any ideas?
Thanks,
Jeff Dahl