java.lang.reflect.Proxy support with native code?

Andrew Haley aph@redhat.com
Tue Jun 15 12:11:00 GMT 2004


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 

1: starting...
2: classloader: gnu.gcj.runtime.VMClassLoader@80b8fc0
3: proxyClass: class $Proxy0
4: constructor: public $Proxy0(java.lang.reflect.InvocationHandler)
5: got proxy! About to invoke...
In invoke...: toString

with mainline on GNU/Linux on i686, so it looks like this may be a
port specific bug.

 > I wonder if the two initial tests die because these are static build, 
 > whereas the final one isn't.

I get the failure when linking statically too, but I wouldn't expect
proxies to work with static linkage: they're about the most dynamic
feature Java gets to have!

Try linking with -Wl,-whole-archive,-lgcj,-no-whole-archive.

Andrew.



More information about the Java mailing list