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 Richard Schilling <rs...@cognitiongroup.biz> on 2009/01/16 22:23:11 UTC
Enhancing using ClassFileTransformer.
Right. After today's meeting, I now understand what
ClassFileTransformer is. It's pretty handy for what we are doing. Per
Craig's e-mail with the notes from today's JDO meeting, I'll be taking a
closer look at instrumentation for this purpose. This is a great
approach, because it allows us a concrete specification to implement
enhancement into build tools. Enhancing during run-time of the
application post-build is another issue, and my understanding from Craig
is that restricting enhancement during the build process is the goal.
That's great too.
The instrumentation interface is so new, that it's kind of hard to find
anything with background information. So, I'll be filling out the JDO
wiki as I go.
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.
Richard
Andy Jefferson wrote:
> Hi Richard,
>
>
>> So, how do we take advantage of the concept of instrumentation and
>> incorporate it into JDO?
>>
>
> "JDOEnhancer" interface extends ClassFileTransformer, consequently it provides
> runtime enhancement also
>
>
Re: Enhancing using ClassFileTransformer.
Posted by Andy Jefferson <an...@datanucleus.org>.
> 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)