aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes How does JavaRebel handle objects created using old class schema? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "How does JavaRebel handle objects created using old class schema?" Watch "How does JavaRebel handle objects created using old class schema?" New topic
Author

How does JavaRebel handle objects created using old class schema?

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10263
    
168

I have been reading replies to some of the posts as to how JavaRebel is different from redeployments in a J2EE application. I have a question related to this. Let's assume, i have a class ABC in my application. Lets further assume that this class has an method "sayHello()". During the course of using the application on the server, i create n instances of this class and store one of the instance in the HTTP session. Then, i go and change the class ABC and remove the method sayHello() from it. This changed class file is put in the application. Then i create another instance of ABC. JavaRebel picks up the changes to the class file and loads a new instance. But what about all the previous instances which were loaded using the old class schema? Does JavaRebel destroy those or are they allowed to stay in the JVM? Normally, in a redeployment process, the old instances are discarded, but how is it in JavaRebel?


[My Blog] [JavaRanch Journal]
Jevgeni Kabanov
Java Rebel Support
Ranch Hand

Joined: Jul 22, 2008
Posts: 32
Originally posted by Jaikiran Pai:
Normally, in a redeployment process, the old instances are discarded, but how is it in JavaRebel?


The whole point of JavaRebel is that all the existing instances are preserved, but their code is updated. So in your case the object in the session will be preserved, but it will now be missing the method "sayHello()" (and will have any methods that you added).

Note that we also allow adding new fields without redeploying. In that case they will not be initialized in the existing instances, so you may get some NPEs until you recreate them.
[ August 13, 2008: Message edited by: Jevgeni Kabanov ]

<a href="http://www.zeroturnaround.com/jrebel/" target="_blank" rel="nofollow">JRebel</a> reloads Java code on-the-fly (<a href="http://www.zeroturnaround.com/jrebel-demonstration-screencast/" target="_blank" rel="nofollow">see demo screencast</a>)
Kuladip Yadav
Ranch Hand

Joined: Jul 30, 2008
Posts: 162

posted Today 03:18 PM Profile for Jevgeni Kabanov Author's Homepage Email Jevgeni Kabanov Send New Private Message Edit/Delete Post Reply With Quote

quote riginally posted by Jaikiran Pai:
Normally, in a redeployment process, the old instances are discarded, but how is it in JavaRebel?



The whole point of JavaRebel is that all the existing instances are preserved, but their code is updated. So in your case the object in the session will be preserved, but it will now be missing the method "sayHello()" (and will have any methods that you added).

Note that we also allow adding new fields without redeploying. In that case they will not be initialized in the existing instances, so you may get some NPEs until you recreate them.


That's the beauty of Java Rebel. Excellent Feature.
[ August 13, 2008: Message edited by: Kuldeep Yadav ]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10263
    
168

Note that we also allow adding new fields without redeploying. In that case they will not be initialized in the existing instances, so you may get some NPEs until you recreate them.


That's a more appropriate example. I was trying to understand how the old objects would behave when the class schema changes. Thanks for the explanation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does JavaRebel handle objects created using old class schema?