such as the number of executed bytecodes. In emerging agent-oriented, context-aware software systems, self-tuning abilities are expected; these will in turn require awareness of resource availability and usage policies. Lastly, in resource-constrained embedded systems, software has to be aware of resource restrictions in order to prevent abnormal termination.
Currently, predominant programming languages and environments, such as Java  and the Java Virtual Machine (JVM) , lack standardized resource management mechanisms. Whereas some pro- totypes have been proposed to address this lack (see the related work section), they are unfortunately all dependent on substantial amounts of native code, and thus prevent the deployment of resource-managed or resource-aware systems throughout widely heterogeneous networks. Therefore, we propose portable resource management with the aid of program transformations. We call our approach J-RAF2 (Java Resource Accounting Framework, 2nd edition) [4, 7, 21], which has been imple- mented in a tool with the same name.1 J-RAF2 is independent of any particular JVM and underlying operating system. It works with stan- dard Java runtime systems and may be integrated into existing server and mobile object environments. Furthermore, this approach enables resource control within embedded systems based on Java processors, which provide a JVM implemented in hardware that cannot be easily modified .
This article concentrates on CPU management, since this is a very useful, and at the same time particularly challenging, resource to study. Program transformations have also been applied to the management of other kinds of resources, such as memory management [7, 14], but the low run-time overheads obtained did not require the development of such advanced analysis and transformation techniques as the ones presented here; notably, they did not involve any control flow or data flow analysis.
The program transformations underlying J-RAF2 were first pub- lished in reference . As the transformations for CPU management incur a certain overhead at runtime, we started developing several optimizations . Applying these techniques to the JDK itself is a difficult task . Finally, we have also presented and illustrated the actual use of J-RAF2 by an application or middleware developer .
The present article is an expanded version of . Its specific, original contributions are:
1. A systematic analysis of the origin of the overheads induced by our CPU accounting scheme.