keywords: bytecode, subclass, dynamic, dynamic loading class
Hi, I'm extremely new to jython, so please forgive me if this is totally insane!
I've tried to find a satisfying answer to the problem I am facing which is the following:
I have a
java class JFoo and I want to subclass it in Jython:
now I would like to get the byte code of the PFoo class (I can go into reasons why -- they're real).
In trying to figure out how to do this I tried the following:
1. hack org.python.core.BytecodeLoader.Loader to contain a HashMap<
String,byte[]> that stores the name and byte[] for the generated proxy class.
2. digging a little deeper I find that I can set a directory to which the Classfile instance is written out to with Options.proxyDebugDirectory
3. rooting around a little more, I came across org.python.modules._bytecodetools, which allows me to register a callback for when new classes are made via BytecodeNotification
For 3 here's the approach:
Anyways, am I on the right track here? Choice 3 seems like the best approach, but I wanted to ask for some guidance.
Thanks!