14.2.2. Dynamic Transformation
Dynamic transformation operates at some time between the JVM request for a class and the loading of that class. Dynamic transformation may occur at the server as specific clients request the class, at an intermediate proxy that transforms classes as they pass through the network [17], or at load time as the classes enter the JVM.
The classloader architecture provided in Java provides a convenient mechanism to alter the semantics of loading a class. A classloader is a user-defined object in Java responsible for locating and obtaining classfiles and handing them to the JVM. While classloaders are intended to enable programmers to control the source location or time of class, they also provide an opportunity for transformation.
Performing the transformation at load time is the only way to guarantee transformation of foreign code, such as applets or servlets loaded from the network. It can apply whole-program transformations to such applications.
In addition to ensuring that every application class supports a given feature, a transformation can also be restrictive, guaranteeing that no application class uses a forbidden feature. For example, a restrictive transformer can limit access to a secure resource by simply disallowing any code that references that resource. The transformer can then safely add its own calls to that resource. Given Java's type-safety, all calls to that resource are guaranteed to be legitimate. (However, see the discussion later on reflection).
Load-time transformation is incremental: The transformer processes individual classes one at a time as they are loaded. The transformer does not control the load order of the classes, and most current JVMs do not allow modification or reloading of already-loaded classes. Transformers thus have only one chance to transform classes and often must do so with incomplete information about the entire application.
This constraint limits the applications for load-time transformation. For example, a dynamic transformer cannot, in general, apply optimizations requiring interprocedural analysis (such as leaf method removal) because the transformation may operate on a call site before the matching method is loaded. Transformer control over the class load order would improve the generality of dynamic transformation but would not solve the problem. For method invocations for which the transformer cannot determine the run-time type of the object, the classloader would require all possible descendents of that object to determine the safety of that method invocation. The current specification of the classfile does not provide that information, and in general, new subclasses may dynamically appear.
请大哥们帮下忙,急用!!!