• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

best practice for getting the byte[] from a jython subclass

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
There are no more "hours", it's centi-days. They say it's better, but this tiny ad says it's stupid:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic