Ice's blog

 

'HotSwapping' using JVM


There was a discussion about this ability of the JVM to perform 'hotswaps', that deserved a closer look...

- This ability is natively provided by JVM in debug mode. Feature available since JDK 1.4.2 (Alex's favourite Java release :)) provided via the Java Debug Interface (http://java.sun.com/j2se/1.4.2/docs/guide/jpda/jdi/com/sun/jdi/VirtualMachine.html)

- Redefine (also known as "HotSwap") was added in 1.4.2: http://java.sun.com/j2se/1.4.2/docs/guide/jpda/enhancements.html

This new feature encapsulates the ability to substitute modified code in a running application through the debugger APIs. For example, one can recompile a single class and replace the old instance with the new instance.

This change was made to address these issues:

* Tool (IDE) vendors want the ability to do fix-and-continue debugging. That is, while debugging, identify a problem, fix it, and continue debugging with fixed code.

* Organizations deploying long running servers wish to be able to fix bugs without taking down the server.

HotSwap adds functionality to the JavaTM Platform Debugger Architecture (JPDA) to allow a class to be updated while under the control of a debugger. The two central components of this functionality are RedefineClasses which replaces the class definitions and PopFrame which pops frames off the stack allowing a method which has been redefined to be re-executed.

In the reference implementation, this functionality is implemented at the Java Virtual Machine Debug Interface (JVMDI) layer and made available through the higher layers of JPDA - the Java Debug Wire Protocol (JDWP) and the Java Debug Interface (JDI).

Redefinition Functionality offered:

    JDI    VirtualMachine.redefineClasses(Map classToBytes)
    JDWP    RedefineClasses (Cmd 18) in VirtualMachine (CmdSet 1)
    JVMDI    RedefineClasses(jint classCount, JVMDI_class_definition *classDefs)

According to the above, HotSwap (on-the-fly class redefinition) can happen only in debug mode. I guess it can't be natively run in normal deployed mode, because I assume that Sun thinks that if the application is already running and deployed, them this hotswap support is not needed. Deployed version is a deployed one, no need to change it, unless you're currently developing it :).

So, the rule should be, if you're developing, always run your applications in debug mode to rip the benefits of JVMs hotswap (on-the-fly class redefinition).

Also, this hotswap can have a dark side, that is, can take up resources incrementaly while in this debugging session, that is, the old (already redefined classes) can be left there and take memory resources, so memory exceptions can take place, but from my experience, this does not occur very often (i have used WTP in this mode for 1 day, without having a single memory exception; assumed that the memory settings of the JVM are properly set). However, having a practice of ocasional restart in debug mode, is always a good idea :)

For the WTP context, to put it in a 'productive development mode', you'll need to make two changes:

- set reloadable="false" on your eclipse configured server, for your application context
- always use debug mode during development

* Interesting development* : HotSwapping with ANT (using Ant task):
- Defines a hotswap target for Ant that allows your build file to replace class definitions on a running JVM. (https://hotswap.dev.java.net/ - java.net incubator project)

Hope this helps,
Ice
 
 
 
 
Comments:

Online Universities

Posted by aaa on декември 14, 2009 at 01:24 PM GMT #

Some people may worry that go down or wear heels on the heel MBT negative health damage, mbt in fact, this worry is unnecessary. For example ballet dancers,ballet movements are numerous, mbt shoes but only five foot position, mbt günstig as five, each pin requires both feet completely out (ie, horizontal) to open. At this point, almost all of the body weight fell on the heel, mbt schuhe negative heel than to wear a larger force, but also to strenuous exercise. Even so, the ballet dancer's heel will not have to be compromised.

Posted by mbt on септември 15, 2011 at 06:12 AM GMT #

It's so tough to encounter right information on the blog. I realy loved reading this post. It has strengthen my faith more used inversion tables | ep 550 inversion table

Posted by rickyjake on ноември 08, 2011 at 09:41 AM GMT #

I appreciate your article very much. Thanks for sharing it. wedding gifts

Posted by elmarie on ноември 17, 2011 at 09:32 AM GMT #

Glad I've found this article. I'll share it to my friend. welding training

Posted by arnoldoh on ноември 17, 2011 at 09:34 AM GMT #

In weve talked Deerfield Beach Flooring prior several other Locksmiths Virginia Beach news fringe from Garage Door Northglenn an individuals entirety Locksmith Lewisville TX just naked for

Posted by polard85 on ноември 22, 2011 at 07:56 AM GMT #

Other than flaunting ghd australia, the reason behind this is to make the collections customer friendly. This applies the most when shipping has to be done and the type of GHD straighteners australia packaging is used to determine the packaging cost. High quality packaging of GHD hair straighteners australia, watches, earrings and other help protect them from getting dust or moisture from the environment

Posted by australia ugg boots on декември 12, 2011 at 05:23 AM GMT #

This is splendid to read about - and I am so happy that you shared it. God bless you and all that jazz! Cooking Training | Business Tips | Good Health Sources | Cheap Flights

Posted by Diet Solutions on декември 21, 2011 at 11:24 PM GMT #

Post a Comment:
  • HTML Syntax: Allowed
 

« февруари 2012
нед.пон.вт.сре.чет.пет.саб.
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
   
       
Today

Valid XHTML or CSS?

[This is a Roller site]
Theme by Rowell Sotto.
 
© ipenov