<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Diego Plentz &#187; jvm</title>
	<atom:link href="http://plentz.org/tag/jvm/feed/" rel="self" type="application/rss+xml" />
	<link>http://plentz.org</link>
	<description>plentiful thoughts from my empty head</description>
	<lastBuildDate>Wed, 07 Dec 2011 16:14:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Hot Swap</title>
		<link>http://plentz.org/2006/11/26/hot-swap/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hot-swap</link>
		<comments>http://plentz.org/2006/11/26/hot-swap/#comments</comments>
		<pubDate>Sun, 26 Nov 2006 10:15:29 +0000</pubDate>
		<dc:creator>Diego Plentz</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[jvm]]></category>

		<guid isPermaLink="false">http://plentz.org/2006/11/26/hot-swap/</guid>
		<description><![CDATA[Segundo a Wikipedia, Hot swapping can also refer to the ability to alter the running code of a program without having to interrupt its execution, although only a few languages support it. Those that do include Lisp, Erlang, and Smalltalk. The Java programming language also supports this technology, but only through the Java Platform Debugger [...]]]></description>
			<content:encoded><![CDATA[<p> <a href="http://www.flickr.com/photos/flowerchild75/306731577/" title="photo sharing"><img src="http://static.flickr.com/100/306731577_7ee75adf7f_m.jpg" alt="" style="border: 2px solid rgb(0, 0, 0);float: right; margin-left: 10px; margin-bottom: 10px;"/></a></p>
<p>Segundo a <a href="http://en.wikipedia.org/wiki/Hot_swap">Wikipedia</a>,</p>
<blockquote><p>Hot swapping can also refer to the ability to alter the running code of a program without having to interrupt its execution, although only a few languages support it. Those that do include <a href="http://en.wikipedia.org/wiki/Lisp_programming_language" title="Lisp programming language">Lisp</a>, <a href="http://en.wikipedia.org/wiki/Erlang_%28programming_language%29" title="Erlang (programming language)">Erlang</a>, and <a href="http://en.wikipedia.org/wiki/Smalltalk_%28programming_language%29" title="Smalltalk (programming language)">Smalltalk</a>. The <a href="http://en.wikipedia.org/wiki/Java_programming_language" title="Java programming language">Java programming language</a> also supports this technology, but only through the <a href="http://en.wikipedia.org/wiki/JPDA" title="JPDA">Java Platform Debugger Architecture (JPDA)</a>&nbsp;: it is only possible to change the code while the program is in the control of a <a href="http://en.wikipedia.org/wiki/Debugger" title="Debugger">Debugger</a>. <a href="http://en.wikipedia.org/wiki/Interactive_programming" title="Interactive programming">Interactive programming</a> is a paradigm that makes extensive use of hot swapping so that the programming activity becomes part of the program flow itself.</p>
</blockquote>
<p>O post do <a href="http://nullability.org/">Daniel</a> (<a href="http://nullability.org/?p=70">Hot Code Replacement</a>), contando como fazer hot swap de classes com o <a href="http://www.oracle.com/technology/tech/java/oc4j/index.html">OC4J</a>, me fez pensar numa coisa: será que realmente são poucos que conhecem a “feature” de trocar classes em tempo de execução, sem parar sua aplicação, e nem a VM?</p>
<p>Bom, mesmo sem ter 1/3 de conhecimento sobre VMs que o <a href="http://www.kumpera.net/blog">Rodrigo</a> (louds), por exemplo, vou tentar explicar. Parada para comentário de utilidade pública: se você não assina o blog dele, faça um favor a si mesmo e <a href="http://www.kumpera.net/blog">vai lá</a>. Hoje mesmo <a href="http://www.kumpera.net/blog/index.php/2006/09/15/rapidinhas/">ele anunciou</a> que vai liberar os fontes da máquina virtual que ele começou a desenvolver. </p>
<p>Voltando ao assunto, desde a <a href="http://java.sun.com/j2se/1.4.2/docs/guide/jpda/enhancements.html#hotswap">JDK 1.4</a> (sim, hot swap é relativamente velho), é possível trocar a implementação de métodos sem reiniciar a aplicação. Notem bem, implementação, ou seja, se você trocou qualquer coisa na assinatura de um método, criou algum novo, adicionou uma variável de instância da classe, você precisa parar a VM, compilar a classe, e iniciar novamente.</p>
<p>No entando, linguagens dinâmicas, como <a href="http://www.ruby-lang.org/en/">Ruby</a> (com site novo), permitem trocar trocar <strong>qualquer coisa</strong> das suas classes em tempo de execução, seja métodos, atributos, whatever. Parece covardia comparar, né?</p>
<p>Porém, lendo um pouco mais à respeito, fazer com que a JVM suporte isso também é perfeitamente possível tecnicamente (louds!!), mas precisariam ser feitas enormes mudanças no seu funcionamento, e acredito que seja esse, um dos principais motivos de não terem feito nos primórdios do hot swap &#8211; JDK 1.4.</p>
<p>O assunto parece estar realmente chamando ateção, pois acabou de sair um artigo no Artima, <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=176597">The JVM as an (Un)Common Language Runtime</a>, e um dos pontos que o autor destaca como sendo um dos principais desafios para a implementação de linguagens dinâmicas na JVM:</p>
<blockquote><p><strong>Hotswapping</strong>: The main idea is to allow code changes on the fly, while they are running. The full capability of hotswapping implies any kind of change to be supported, addition/modification/removal of methods and attributes including changes in inheritance hierarchy.</p>
</blockquote>
<p>Se isso não fosse suficiente, existe um tópico na SDN, <a href="http://forum.java.sun.com/thread.jspa?forumID=47&amp;threadID=572396">Hotswap support for schema / shape changes</a> discutindo o assunto, e o bug report <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4910812">4910812 &#8211; Enhance Hot Code Replacement</a> com 300+ votos.</p>
<p>Isso permitiria baixar para praticamente zero o turnaround de desenvolivmento de aplicações, dando um grande fôlego para Java como linguagem, pois já aumentaria significantemente a velocidade de desenvolvimento, evitando a perda de minutos que já estamos acostumados entre parar servidor de aplicação, fazer re-deploy, iniciar aplicação, …</p>
<blockquote><p>Classloader tricks only take you so far.</p>
</blockquote>
<div class="acc_license"><a href="http://creativecommons.org/licenses/by-nc-nd/3.0/"><img src="http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png" alt="by-nc-nd" /></a></div><!--<rdf:RDF xmlns="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><Work rdf:about=""><license rdf:resource="http://creativecommons.org/licenses/by-nc-nd/3.0/" /></Work><License rdf:about="http://creativecommons.org/licenses/by-nc-nd/3.0/"><requires rdf:resource="http://creativecommons.org/ns#Attribution" /><permits rdf:resource="http://creativecommons.org/ns#Reproduction" /><permits rdf:resource="http://creativecommons.org/ns#Distribution" /><prohibits rdf:resource="http://creativecommons.org/ns#CommercialUse" /><requires rdf:resource="http://creativecommons.org/ns#Notice" /></License></rdf:RDF>--><img src="http://plentz.org/wordpress/?ak_action=api_record_view&id=143&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://plentz.org/2006/11/26/hot-swap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

