You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Andy Jefferson <an...@datanucleus.org> on 2009/01/22 20:40:36 UTC

Re: Enhancing using ClassFileTransformer.

> Quick question: Can anyone post a link with a description (or just
> describe it here) of how the VM interacts with the instrumentation API
> to process the bytestream of a class using ClassFileTransformer?
> Does the VM invoke the class loader to find a class first, before
> handing the class definition off to the ClassFileTransformer?  I assume
> this is so but I want to be sure.

From what I remember the JVM will receive a request to load a class. It 
retrieves the bytes of the class. It then calls the method "transform" of 
the "Premain-Class" (specified in the MANIFEST.MF of the enhancer jar) with 
the input bytes for the class. This method can transform the bytecode of that 
class and return it, or return null (meaning there is no change to the class 
definition).

See
http://datanucleus.svn.sourceforge.net/viewvc/datanucleus/platform/enhancer/trunk/src/java/org/datanucleus/enhancer/DataNucleusClassFileTransformer.java?revision=2302&view=markup

That's about it.

-- 
Andy  (DataNucleus - http://www.datanucleus.org)