This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: java.lang.reflect.Proxy support with native code?
Martin Egholm Nielsen writes:
>
> > > > > In my progress of porting my existing code to gcj, I've run into some
> > > > > problems with java.lang.reflect.Proxy.
> > > > > When running the compiled code I get a java.lang.NoClassDefFoundError
> > > > > exception thrown for "$Proxy0"...
> > > > > Is there an issue with java.lang.reflect.Proxy when running natively
> > > > > compiled code?
> > > > I've used it quite a lot with native code. Let's have simple test
> > > > case, and we'll see what happens.
> > > I've attached a simple example, and below is the outcome of executing:
> > I get
> === SNIP ===
> > with mainline on GNU/Linux on i686, so it looks like this may be a
> > port specific bug.
> May be so, I'm afraid...
>
> > Try linking with -Wl,-whole-archive,-lgcj,-no-whole-archive.
> That's actually solves the problem under both MinGW and Cygwin - great!
> Whatever they mean?
It links with all of libgcj, not just the bits you used.
Java is a very dynamic language: you can generate code at runtime that
calls anything in any library. So, the linker has no way to know what
code should be linked in. Errors with -static aren't even bugs, it's
just to be expected.
> However, if I try that on target with "-static", I get an "Illegal
> Instruction" before anything else is even printed... There seems to be
> an error with my cross-compiler...
Yup.
Andrew.