classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Instrumentation in the generics branch


From: Nicolas Geoffray
Subject: Instrumentation in the generics branch
Date: Sat, 03 Dec 2005 16:59:53 +0100
User-agent: Mozilla Thunderbird 1.0.7 (X11/20051019)

Hi all,

A new feature has appeared in the generics branch : it now contains an implementation of the instrument package. The instrument package of java 1.5 allows a programmer to modify the bytecode of a class when the class is defined or redefined. Definition occurs
with calls to ClassLoader.defineClass and redefinition occurs with calls to
Instrumentation.redefineClasses.

Modifications are done by giving a list of ClassFileTransformers to a Instrumentation object. The programmer receives from the VM an instrumentation object by call of a "premain" function of a class (called an agent). The signature of the premain function is :

public static void premain(String agentArgs, Instrumentation inst)

An agent is given by the vm in the command line |*:
**-javaagent:*|/jarpath[/|*=*|/options]


/the jarpath is a .jar whose manifest contains a Premain-Class entry. A programmer
can give one or more agents to the vm.

GNU classpath can not do all work for realizing instrumentation : it needs the vm to
read the command line, instantiate an Instrumentation object
(the default is java/langInstrumentationImpl in classpath), and call each agent by calling their premain method. The vm has also to modify its defineClass in order to trigger transformation done by ClassFileTransformers referenced by the InstrumentationImpl
object.

We are working on a default (non functionnal of course, as it still needs works from the vm)
implementation in classpath. Things might break the current VM interface of
the ClassLoader/VMClassLoader.redefineClass. The NEWS file will inform about
possible evolutions (nothing will be changed untill the release of 0.20 generics)

Cheers,
Nicolas







reply via email to

[Prev in Thread] Current Thread [Next in Thread]