Serialization

Tom Tromey tromey@cygnus.com
Fri Jul 2 00:38:00 GMT 1999


Geoff> I have almost finished porting my serialization classes from
Geoff> the Classpath project but cannot proceed without more
Geoff> native/reflection support.

That's cool.  Did you write these classes?  Do you hold the copyright?
I'm asking because if you don't, or if you aren't willing to sign
papers for us, then we'll have to rewrite the classes anyway.  Bummer.

Geoff> 	get and set fields given a Class* and a field name

Seems like this part of java.lang.reflect ought to work.

Geoff> 	check to see if a Class* implements a method

You can duplicate the logic from _Jv_LookupInterfaceMethod of calling
_Jv_GetMethodLocal and searching up the class hierarchy.

Using this function is "dangerous" in the sense that it is not
exported and are subject to change.  CNI as a whole isn't really
exported yet -- we want to do a header file reorg before we start
installing the headers and telling people that it is usable.

You'll be safe enough in the short term, but don't complain if a
future release breaks your code.

Geoff> 	call a method given a Class* and a method signature

This is about 80% written.  See java/lang/reflect/natMethod.cc and
look for the FIXME comments to see what is missing.  Making it work
completely is kind of painful (writing the exception-handling
trampoline I find particularly distasteful).  Also, you'd have to get
libffi (easy), hook it into the build process (easy), and turn it into
a target library (easy, but probably confusing if you've never done it
before).

Even more work is involved if you need to run constructors.

Geoff> Is anyone working on this?  I'm *so* close!

Nobody is working on it right now.  Reflection is something I hope to
"finish" (get working but still not fully complete -- for instance we
can't get the security stuff right without compiler changes)
"sometime" -- but I don't know when that will be.

Tom


More information about the Java mailing list