You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by "Jimmy, Jing Lv" <fi...@gmail.com> on 2006/07/31 10:29:02 UTC

[classlib] Intention to work on java.lang.instrument

Hi everyone,

     Though Harmony VM 5 hasn't appeared yet(I hope it ready in the near 
further), I'd like to start work on an implementation of the 
java.lang.instrument[1].
     After some study on this, I find Java interface classes/interfaces 
are quite easy, but there should be real implement, both in java and 
native. And the native code requires JVMTI[2], which is a part of VM 5. 
Though, luckily we can still study and code according to JVMTI and test 
on RI. So my goal is : 1.define those simple Java classes/interfaces in 
Harmony; 2. work out implementation of java/native code according to 
JVMTI and make it run on RI; 3. wait for Harmony VM5 and then make some 
integration modification/test.
     According to Harmony naming convention, I think the implementation 
class should be in org.apache.harmony.luni.internal.lang.instrument(a 
little too long, is it necessary to cut it shorter?).
     One problem is that it may have no suitable unit test for its 
implementation(except for some easy ones for exception class, etc), as 
all tests on this requires starting a VM to run. If I'm not wrong, I 
remember there's some of implementation also meet this problem, e.g, 
InheritedChannel. For this non-unit-testable implementation, shall 
Harmony contain some non-unit-test(some small application), or at least 
some document(How to use/test) to ensure its quality?

     Any comments and advices? Thanks!

[1]http://java.sun.com/j2se/1.5.0/docs/api/java/lang/instrument/package-summary.html
[2]http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html

-- 

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Intention to work on java.lang.instrument

Posted by Leo Li <li...@gmail.com>.
On 8/1/06, Gregory Shimansky <gs...@gmail.com> wrote:
>
> On Tuesday 01 August 2006 09:47 Leo Li wrote:
> > > I agree with this approach. Do you know which API functions and events
> > > you will need for such agent?
> >
> >  Hi, we will need VM Initialization Event to run premain functions and
> > Class File Load Hook Event for agents to instruct the existing class
> file.
> > As to the jvmti API, we need RedefineClasses,GetObjectSize and Allocate.
> > Besides, AddCapabilities is also required to turn on the capability of
> the
> > VM, such as can_generate_all_class_hook_events and can_redefine_classes.
> >
> > Since we have just planned to implement this module, please excuse me if
> I
> > leave some requirements about it. :)
>
> It is not a problem. I just wanted to know which areas are required, not
> every
> single API function :)
>
> All of the functions and events that you mentioned are implemented already
> except for RedefineClasses. It is on the TODO list for drlvm.


Good! Maybe we can test instruments on drlvm some day.:)

--
> Gregory Shimansky, Intel Middleware Products Division
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Leo Li
China Software Development Lab, IBM

Re: [classlib] Intention to work on java.lang.instrument

Posted by Gregory Shimansky <gs...@gmail.com>.
On Tuesday 01 August 2006 09:47 Leo Li wrote:
> > I agree with this approach. Do you know which API functions and events
> > you will need for such agent?
>
>  Hi, we will need VM Initialization Event to run premain functions and
> Class File Load Hook Event for agents to instruct the existing class file.
> As to the jvmti API, we need RedefineClasses,GetObjectSize and Allocate.
> Besides, AddCapabilities is also required to turn on the capability of the
> VM, such as can_generate_all_class_hook_events and can_redefine_classes.
>
> Since we have just planned to implement this module, please excuse me if I
> leave some requirements about it. :)

It is not a problem. I just wanted to know which areas are required, not every 
single API function :)

All of the functions and events that you mentioned are implemented already 
except for RedefineClasses. It is on the TODO list for drlvm.

-- 
Gregory Shimansky, Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Intention to work on java.lang.instrument

Posted by "Jimmy, Jing Lv" <fi...@gmail.com>.
Leo Li wrote:
> On 7/31/06, Gregory Shimansky <gs...@gmail.com> wrote:
>>
>> 2006/7/31, Jimmy, Jing Lv <fi...@gmail.com>:
>> >
>> > >       Besides, Harmony VM now has actually support the feature of
>> JVMTI
>> > > on which we can implement instrument.
>> > >
>> >
>> > Ah, can it work now? It'll be great convenient if so.
>>
>>
>> Hello. The drlvm does support a subset of JVMTI. Class loading events are
>> supported, ClassFileLoadHook which may be used for load time class
>> instrumentation is supported too. But there is no support for
>> RedefineClasses yet if you need to change classes bytecode after the 
>> class
>> was loaded already.
>>
>> >
>> > >    After some study on this, I find Java interface classes/interfaces
>> > >> are quite easy, but there should be real implement, both in java and
>> > >> native. And the native code requires JVMTI[2], which is a part of VM
>> 5.
>> > >> Though, luckily we can still study and code according to JVMTI and
>> test
>> > >> on RI. So my goal is : 1.define those simple Java classes/interfaces
>> in
>> > >> Harmony; 2. work out implementation of java/native code according to
>> > >> JVMTI and make it run on RI; 3. wait for Harmony VM5 and then make
>> some
>> > >> integration modification/test.
>> > >
>> > >
>> > >      As the main function of instruments is to add and remove
>> > transformers
>> > > to some classes, I suggest implement it as an agent of JVMTI. That is
>> to
>> > > register callback functions, which actually transform the byte stream
>> of
>> > > some specified classes,  to the events that is relevent to instrument
>> in
>> > > JVMTI including
>> > > the class loading.
>> > >
>> >
>> > Yes, that's the way.
>>
>>
>> I agree with this approach. Do you know which API functions and events 
>> you
>> will need for such agent?
> 

Thanks you Gregory :) Refer to JVMTI Functions doc[1], I think functions 
of Memory Management/Class/Capability is necessary.

[1]http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#FunctionIndex

> 
> Hi, we will need VM Initialization Event to run premain functions and Class
> File Load Hook Event for agents to instruct the existing class file. As to
> the jvmti API, we need RedefineClasses,GetObjectSize and Allocate. Besides,
> AddCapabilities is also required to turn on the capability of the VM, such
> as can_generate_all_class_hook_events and can_redefine_classes.
> 

That's detail, thanks :)

> Since we have just planned to implement this module, please excuse me if I
> leave some requirements about it. :)
> 

And for VM guys ,the launcher with parameter "-javaagent":)

> 
> 
>> -- 
>> Gregory Shimansky, Intel Middleware Products Division
>>
>>
> 
> 


-- 

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Intention to work on java.lang.instrument

Posted by Leo Li <li...@gmail.com>.
On 7/31/06, Gregory Shimansky <gs...@gmail.com> wrote:
>
> 2006/7/31, Jimmy, Jing Lv <fi...@gmail.com>:
> >
> > >       Besides, Harmony VM now has actually support the feature of
> JVMTI
> > > on which we can implement instrument.
> > >
> >
> > Ah, can it work now? It'll be great convenient if so.
>
>
> Hello. The drlvm does support a subset of JVMTI. Class loading events are
> supported, ClassFileLoadHook which may be used for load time class
> instrumentation is supported too. But there is no support for
> RedefineClasses yet if you need to change classes bytecode after the class
> was loaded already.
>
> >
> > >    After some study on this, I find Java interface classes/interfaces
> > >> are quite easy, but there should be real implement, both in java and
> > >> native. And the native code requires JVMTI[2], which is a part of VM
> 5.
> > >> Though, luckily we can still study and code according to JVMTI and
> test
> > >> on RI. So my goal is : 1.define those simple Java classes/interfaces
> in
> > >> Harmony; 2. work out implementation of java/native code according to
> > >> JVMTI and make it run on RI; 3. wait for Harmony VM5 and then make
> some
> > >> integration modification/test.
> > >
> > >
> > >      As the main function of instruments is to add and remove
> > transformers
> > > to some classes, I suggest implement it as an agent of JVMTI. That is
> to
> > > register callback functions, which actually transform the byte stream
> of
> > > some specified classes,  to the events that is relevent to instrument
> in
> > > JVMTI including
> > > the class loading.
> > >
> >
> > Yes, that's the way.
>
>
> I agree with this approach. Do you know which API functions and events you
> will need for such agent?


 Hi, we will need VM Initialization Event to run premain functions and Class
File Load Hook Event for agents to instruct the existing class file. As to
the jvmti API, we need RedefineClasses,GetObjectSize and Allocate. Besides,
AddCapabilities is also required to turn on the capability of the VM, such
as can_generate_all_class_hook_events and can_redefine_classes.

Since we have just planned to implement this module, please excuse me if I
leave some requirements about it. :)



> --
> Gregory Shimansky, Intel Middleware Products Division
>
>


-- 
Leo Li
China Software Development Lab, IBM

Re: [classlib] Intention to work on java.lang.instrument

Posted by Gregory Shimansky <gs...@gmail.com>.
2006/7/31, Jimmy, Jing Lv <fi...@gmail.com>:
>
> >       Besides, Harmony VM now has actually support the feature of JVMTI
> > on which we can implement instrument.
> >
>
> Ah, can it work now? It'll be great convenient if so.


Hello. The drlvm does support a subset of JVMTI. Class loading events are
supported, ClassFileLoadHook which may be used for load time class
instrumentation is supported too. But there is no support for
RedefineClasses yet if you need to change classes bytecode after the class
was loaded already.

>
> >    After some study on this, I find Java interface classes/interfaces
> >> are quite easy, but there should be real implement, both in java and
> >> native. And the native code requires JVMTI[2], which is a part of VM 5.
> >> Though, luckily we can still study and code according to JVMTI and test
> >> on RI. So my goal is : 1.define those simple Java classes/interfaces in
> >> Harmony; 2. work out implementation of java/native code according to
> >> JVMTI and make it run on RI; 3. wait for Harmony VM5 and then make some
> >> integration modification/test.
> >
> >
> >      As the main function of instruments is to add and remove
> transformers
> > to some classes, I suggest implement it as an agent of JVMTI. That is to
> > register callback functions, which actually transform the byte stream of
> > some specified classes,  to the events that is relevent to instrument in
> > JVMTI including
> > the class loading.
> >
>
> Yes, that's the way.


I agree with this approach. Do you know which API functions and events you
will need for such agent?

-- 
Gregory Shimansky, Intel Middleware Products Division

Re: [classlib] Intention to work on java.lang.instrument

Posted by "Jimmy, Jing Lv" <fi...@gmail.com>.
Leo Li wrote:
> On 7/31/06, Jimmy, Jing Lv <fi...@gmail.com> wrote:
>>
>> Hi everyone,
>>
>>     Though Harmony VM 5 hasn't appeared yet(I hope it ready in the near
>> further), I'd like to start work on an implementation of the
>> java.lang.instrument[1].
> 
> 
> 
> 
> Hi,
>      I am also interested in working on java.lang.instrument.

Great! Welcome. :)

>       Besides, Harmony VM now has actually support the feature of JVMTI
> on which we can implement instrument.
> 

Ah, can it work now? It'll be great convenient if so.

> 
>    After some study on this, I find Java interface classes/interfaces
>> are quite easy, but there should be real implement, both in java and
>> native. And the native code requires JVMTI[2], which is a part of VM 5.
>> Though, luckily we can still study and code according to JVMTI and test
>> on RI. So my goal is : 1.define those simple Java classes/interfaces in
>> Harmony; 2. work out implementation of java/native code according to
>> JVMTI and make it run on RI; 3. wait for Harmony VM5 and then make some
>> integration modification/test.
> 
> 
>      As the main function of instruments is to add and remove transformers
> to some classes, I suggest implement it as an agent of JVMTI. That is to
> register callback functions, which actually transform the byte stream of
> some specified classes,  to the events that is relevent to instrument in
> JVMTI including
> the class loading.
> 

Yes, that's the way.

>    According to Harmony naming convention, I think the implementation
>> class should be in org.apache.harmony.luni.internal.lang.instrument(a
>> little too long, is it necessary to cut it shorter?).
>>     One problem is that it may have no suitable unit test for its
>> implementation(except for some easy ones for exception class, etc), as
>> all tests on this requires starting a VM to run. If I'm not wrong, I
>> remember there's some of implementation also meet this problem, e.g,
>> InheritedChannel. For this non-unit-testable implementation, shall
>> Harmony contain some non-unit-test(some small application), or at least
>> some document(How to use/test) to ensure its quality?
> 
> 
>     Ya, although we are able to test them both on RI and Harmony now,  the
> testcases
> of instruments require lauch options of java VM, which lead to the
> difficult to add them
> to current Harmony testcases.
> 

Yes, Harmony launcher may also be modified (adding parameter for 
javaagent, etc).
However I mean, without unit-test, shall Harmony have some other 
quality-assurance technique?

>    Any comments and advices? Thanks!
>>
>> [1]http://java.sun.com/j2se/1.5.0/docs/api/java/lang/instrument/package-
>> summary.html
>> [2]http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html
>>
>> -- 
>>
>> Best Regards!
>>
>> Jimmy, Jing Lv
>> China Software Development Lab, IBM
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
> 
> 


-- 

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] Intention to work on java.lang.instrument

Posted by Leo Li <li...@gmail.com>.
On 7/31/06, Jimmy, Jing Lv <fi...@gmail.com> wrote:
>
> Hi everyone,
>
>     Though Harmony VM 5 hasn't appeared yet(I hope it ready in the near
> further), I'd like to start work on an implementation of the
> java.lang.instrument[1].




 Hi,
      I am also interested in working on java.lang.instrument.
       Besides, Harmony VM now has actually support the feature of JVMTI
on which we can implement instrument.


    After some study on this, I find Java interface classes/interfaces
> are quite easy, but there should be real implement, both in java and
> native. And the native code requires JVMTI[2], which is a part of VM 5.
> Though, luckily we can still study and code according to JVMTI and test
> on RI. So my goal is : 1.define those simple Java classes/interfaces in
> Harmony; 2. work out implementation of java/native code according to
> JVMTI and make it run on RI; 3. wait for Harmony VM5 and then make some
> integration modification/test.


      As the main function of instruments is to add and remove transformers
to some classes, I suggest implement it as an agent of JVMTI. That is to
register callback functions, which actually transform the byte stream of
some specified classes,  to the events that is relevent to instrument in
JVMTI including
the class loading.

    According to Harmony naming convention, I think the implementation
> class should be in org.apache.harmony.luni.internal.lang.instrument(a
> little too long, is it necessary to cut it shorter?).
>     One problem is that it may have no suitable unit test for its
> implementation(except for some easy ones for exception class, etc), as
> all tests on this requires starting a VM to run. If I'm not wrong, I
> remember there's some of implementation also meet this problem, e.g,
> InheritedChannel. For this non-unit-testable implementation, shall
> Harmony contain some non-unit-test(some small application), or at least
> some document(How to use/test) to ensure its quality?


     Ya, although we are able to test them both on RI and Harmony now,  the
testcases
 of instruments require lauch options of java VM, which lead to the
difficult to add them
 to current Harmony testcases.

    Any comments and advices? Thanks!
>
> [1]http://java.sun.com/j2se/1.5.0/docs/api/java/lang/instrument/package-
> summary.html
> [2]http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html
>
> --
>
> Best Regards!
>
> Jimmy, Jing Lv
> China Software Development Lab, IBM
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Leo Li
China Software Development Lab, IBM