Before I bother to get it to a releasable point for others (or
admitting ownership of the code <g>), I wanted to find out a couple of
things:
- Does something like this already exist (instantiate JVM classes via
a system-local JVM, call methods on those objects, and get return
values -- from a go program) that's further along?
- Is there any outside interest?
Semantic limitations that I'd love suggestions on (in or out of the
JVM context):
- It does not seem possible in go, to dynamically define a struct,
or to attach a method to a struct, making a "magic"
'(&Object).AReflectedName(...)' impossible?
* A possible work around is something like
'(&Object).Functions["AReflectedName"](...)', but I can't think of a
way to 'sugar-over' that from the Go side.
* It is entirely probable that this could be accomplished by
substantial reflection on the Java side, but I'd like to avoid having
to ship too many Java 'stubs'.
- The JVM seems to be very concerned that thread calls are sourced
from the same context - my implementation does basic refcounting for
java, but not thread-checking.
I know syscall.Fork() does some magic w/r/t FD's, but I'm not sure
there's a way to 'hook' that in order to appropriately handle TLS for
java.
- I vaguely remember seeing something that a GOC user could do to
hook the collection of an object, but can no longer find any reference
to it,
does such functionality exist any longer?
Thanks for any thoughts,
James
P.S. It occurs to me that someone will likely ask if this would allow
some other JVM-compiled language to work, and the answer is 'probably,
depending on how closely
it follows certain semantics of Java that are not entirely specific to
the JVM', and if you're interested in talking shop/finding out, I'm
happy to share my code & notes, but I am not,
nor will ever claim to be, a Java/JVM expert =).
- Evan
Regards,
Brian Ketelsen
https://github.com/abneptis/GoJVM
Straight CGo & C, no Swig (though after getting it to work, I'm not
wholly certain thats a good thing <g>).
(Goinstall will fail, but if you clone and run 'make java_classes',
the rest should build fine)
I hope it does someone else some good :)
-James