90 likes | 208 Views
New debug/profile features in J2SE 6. Ivan Popov, May, 2006 Intel Corporation. New features in J2SE 6 (JSR-270, core/debug). Access to heap contents (JDI, JDWP) rewritten JVMTI functions and callbacks for heap iteration new JDI and JDWP functions for finding objects in heap
E N D
New debug/profile features in J2SE 6 Ivan Popov, May, 2006 Intel Corporation
New features in J2SE 6 (JSR-270, core/debug) • Access to heap contents (JDI, JDWP) • rewritten JVMTI functions and callbacks for heap iteration • new JDI and JDWP functions for finding objects in heap • Attach-on-demand (JVMTI, java.lang.instrument) • new entry points for dynamically loaded JVMTI and Java agents • no spec for dynamic loading mechanism (implementation dependent) • Multiple simultaneous agents (JVMTI, java.lang.instrument) • defined algorithm of sequential classfile transformation • introduced transformation capable/incapable agents • new function RetransformClasses() in addition to RedefineClasses() • support for instrumenting native calls by providing Java wrappers • Several other changes in JVMTI, JDI, JDWP • Getting monitor info for stack frames, access to constant pool, etc. • JVMDI and JVMPI are removed
Access to heap content • JVMTI • new set of heap iteration functions and callbacks • similar functionality but new design • old functions are still in JVMTI spec (marked version 1.0) • JDI/JDWP • Get all objects of a given class • Get all objects which refer to a given object
Attach-on-demand • JVMTI: • new entry point for dynamically loaded JVMTI agents • Agent_OnAttach() vs. Agent_OnLoad() • java.lang.instrument: • new entry point for dynamically loaded Java agents • agentmain() vs. premain() • Problems: • no spec for algorithm of dynamic agent loading – it is implementation specific • no particular support for detach-on-demand
Multiple simultaneous agents (bytecode instrumentation) • JVMTI: • described support for multiple classfile transformations • introduced classfile retransformation algorithm for new transformation capable agents • supports classfile redefinition algorithm for old transformation incapable agents • clarified semantics of RedefineClasses(), RetransformClasses(), CLASS_FILE_LOAD_HOOK for agents of both kinds • the whole algorithm is quite sophisticated • java.lang.instrument: • similar features for Java agents
New features in J2SE 6 (JSR-270, core/debug) • Access to heap contents (JDI, JDWP) • rewritten JVMTI functions and callbacks for heap iteration • new JDI and JDWP functions for finding objects in heap • Attach-on-demand (JVMTI, java.lang.instrument) • new entry points for dynamically loaded JVMTI and Java agents • no spec for dynamic loading mechanism (implementation dependent) • Multiple simultaneous agents (JVMTI, java.lang.instrument) • defined algorithm of sequential classfile transformation • introduced transformation capable/incapable agents • new function RetransformClasses() in addition to RedefineClasses() • support for instrumenting native calls by providing Java wrappers • Several other changes in JVMTI, JDI, JDWP • Getting monitor info for stack frames, access to constant pool, etc. • JVMDI and JVMPI are removed
Instrumenting native calls • JVMTI: • replacing native methods with Java wrappers • adding prefixes for renaming original native methods • managing prefixes for single and multiple agents • clarified algorithm for binding native methods using prefixes • the overall algorithm is quite sophisticated
Other spec changes • JVMTI, JDWP, JDI: • Get locked monitors for frames • new functions return association between frames and locked monitors • support for monitor events on JDI/JDWP level • Access to constant pool • get classfile major/minor version • get constant pool bytes • Checking unmodifiable classes • new function checks if class bytecode can be modified • Force early method return • new function to force method to return with given value • new METHOD_EXIT_WITH_RETURN_VALUE event in JDI/JDWP
Other spec changes (cont.) • JVMTI: • modification of class path for both bootstrap and system loaders: • AddToSystemClassLoaderSearch vs. AddToBootstrapClassLoaderSearch • JDI/JDWP: • source file filter for CLASS_PREPARE events • new JDI connector ProcessAttach uses PID for attaching to process • eliminates knowing port number for attaching connection • transport is determined dynamically and reported as “local” • no details of the algorithm