<?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>SemtexGirl</title>
	<atom:link href="http://www.semtexgirl.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.semtexgirl.net</link>
	<description>É uma garota dinâmica e de bom gosto, uma garota que explode, que não para e nem aceita um não como resposta.</description>
	<lastBuildDate>Sat, 01 May 2010 16:26:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Modelos profissionais</title>
		<link>http://www.semtexgirl.net/2010/05/01/modelos-profissionais/</link>
		<comments>http://www.semtexgirl.net/2010/05/01/modelos-profissionais/#comments</comments>
		<pubDate>Sat, 01 May 2010 16:06:55 +0000</pubDate>
		<dc:creator>Andréia Bustamante</dc:creator>
				<category><![CDATA[globo.com]]></category>

		<guid isPermaLink="false">http://www.semtexgirl.net/?p=152</guid>
		<description><![CDATA[Sempre gostei de me espelhar em modelos, pessoas com as quais trabalhei e que conquistaram a minha admiração e respeito. Entre tantos que já conheci existe um que me marcou profundamente, Jorge Ogawa, meu gerente na época em que eu trabalhava no Itaú, como todo mundo ele não acertava sempre, as vezes tomava decisões que [...]]]></description>
			<content:encoded><![CDATA[<p>Sempre gostei de me espelhar em modelos, pessoas com as quais trabalhei e que conquistaram a minha admiração e respeito. Entre tantos que já conheci existe um que me marcou profundamente, <strong>Jorge Ogawa</strong>, meu gerente na época em que eu trabalhava no <strong>Itaú</strong>, como todo mundo ele não acertava sempre, as vezes tomava decisões que me deixavam chateada mas no geral ele sempre foi e ainda é a  minha inspiração.</p>
<p>Quando comecei a trabalhar com gestão de equipe comecei a dizer a mim mesma, espero um dia ser para a minha equipe ao menos metade do que o Jorge foi pra mim. Ele é um grande líder, exigente, sempre soube quando elogiar ou puxar a orelha de alguém da equipe, sempre se preocupou com a evolução técnica e pessoal de todos.</p>
<p>Muitas vezes no meu dia-a-dia quando me encontro em situações complicadas com a minha equipe eu paro e penso, o que o Jorge faria no meu lugar? E tento imaginar e encontrar uma solução inspirada no que aprendi com ele.</p>
<p>Porem esta semana aconteceu algo curioso, eu estava um pouco chateada com uma série de coisas, estava questionando a qualidade do meu trabalho,  questionando tudo que tenho feito na globo.com e não conseguia ver nenhum  resultado relevante, e ontem cheguei a comentar com alguns poucos amigos que talvez eu saísse da empresa, pois eu não estava conseguindo atingir minhas metas pessoais, e contei sobre o meu modelo profissional e que eu estava me questionando se de fato eu tinha conseguido aprender alguma coisa com o ele. Porem, no final do dia recebi um e-mail de alguém de uma das equipes que trabalhei na Globo.com que vou transcrever abaixo:</p>
<blockquote><p><em>Andréia,</em></p>
<p><em>Sinceramente, queria muito que você ficasse aqui conosco, por tudo que você já fez e na minha humilde opinião, por tudo que você representa.</em></p>
<p><em>Acho que, pelo menos para algumas pessoas daqui de dentro, você é o ultimo símbolo de esperança de alguma mudança na globo. E com a sua saída, essa esperança vai por água a baixo.</em></p>
<p><em>Mas, obviamente que eu sei que você tem que seguir seus princípios e sua vontade mas sinceramente, ainda tenho uma esperança que você fique.</em></p>
<p><em>E ficando ou não, eu queria repetir uma frase que você falou ainda a pouco...</em></p>
<p><em>Se um dia eu puder exercer um cargo de gerência em alguma empresa, e se eu for metade do que você é, sinceramente estarei mega feliz.</em></p>
<p><em>Não quero que você veja essas palavras apenas como palavras de uma pessoa que gosta de você, quero que você as veja como palavras de uma pessoa que te admira bastante e te tem como um ótimo exemplo a se seguir.</em></p></blockquote>
<p>Confesso que fiquei um bocado emocionada, pois sei que é muito difícil fazer a diferença na vida de alguém e saber que de alguma forma eu consegui fazer isso, me encheu de esperança e me fez ver as coisas de um outro ponto de vista e que as vezes a gente não consegue ver o resultado do nosso trabalho, pois ser Scrum Master é um trabalho de formiguinha, todo dia você tenta mudar uma coisinha e torce para que isso dê resultado, e muitas vezes o resultado não é visível a curto prazo, nem para mim nem para os outros.</p>
<p>Sendo assim agradeço publicamente a pessoa que mandou ao e-mail,  e fecho dizendo que não consigo expressar o quanto este e-mail significou pra mim. E agradeço ao meu amigo e "ex-chefinho" Jorge Ogawa, pelos 5 anos que tive o prazer e a honra de trabalhar ao seu lado.</p>
<p id="tt_tweet" align="left"><a class="tt" href="http://twitter.com/home/?status=Modelos+profissionais+http://bit.ly/bVvWSa" title="Post no twitter"><img class="img_tt" src="http://www.semtexgirl.net/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Modelos+profissionais+http://bit.ly/bVvWSa" title="Post no twitter">Tweet este post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.semtexgirl.net/2010/05/01/modelos-profissionais/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyActiveMQ + Mac OS X Snow Leopard</title>
		<link>http://www.semtexgirl.net/2010/01/15/pyactivemq-mac-os-x-snow-leopard/</link>
		<comments>http://www.semtexgirl.net/2010/01/15/pyactivemq-mac-os-x-snow-leopard/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 03:39:14 +0000</pubDate>
		<dc:creator>Andréia Bustamante</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[ActiveMQ-CPP]]></category>
		<category><![CDATA[Boost]]></category>
		<category><![CDATA[Mac OS X Snow Leopard]]></category>
		<category><![CDATA[PyActiveMQ]]></category>

		<guid isPermaLink="false">http://www.semtexgirl.net/?p=125</guid>
		<description><![CDATA[Só uma dica, para o tutorial de instalação/compilação do activemq no Leopard funcionar com o Snow Leopard, depois que executar o passo 2 faça o seguinte:

cd /System/Library/Frameworks/Python.framework/Versions/
mv 2.6 2.6Old
sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.6 2.6

E depois executar os demais passos... a dica acima tambem serve para o python 2.5 rodando no Leopard ou Snow Leopard.
 Tweet este [...]]]></description>
			<content:encoded><![CDATA[<p>Só uma dica, para o <a href="http://www.semtexgirl.net/2009/07/24/compilando-o-pyactivemq-activemq-cpp-no-mac-os-x-leopard/">tutorial de instalação/compilação do activemq no Leopard</a> funcionar com o Snow Leopard, depois que executar o passo 2 faça o seguinte:</p>
<blockquote>
<pre class="bash"><span style="color: #7a0874; font-weight: bold;">cd</span> /System/Library/Frameworks/Python.framework/Versions/
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000;">2.6</span> <span style="color: #000000;">2</span>.6Old
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> -s /opt/<span style="color: #7a0874; font-weight: bold;">local</span>/Library/Frameworks/Python.framework/Versions/<span style="color: #000000;">2.6</span> <span style="color: #000000;">2.6</span></pre>
</blockquote>
<p>E depois executar os demais passos... a dica acima tambem serve para o python 2.5 rodando no Leopard ou Snow Leopard.</p>
<p id="tt_tweet" align="left"><a class="tt" href="http://twitter.com/home/?status=PyActiveMQ+%2B+Mac+OS+X+Snow+Leopard+http://bit.ly/d9qUro" title="Post no twitter"><img class="img_tt" src="http://www.semtexgirl.net/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=PyActiveMQ+%2B+Mac+OS+X+Snow+Leopard+http://bit.ly/d9qUro" title="Post no twitter">Tweet este post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.semtexgirl.net/2010/01/15/pyactivemq-mac-os-x-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UnicodeDecodeError: &#039;ascii&#039; codec can&#039;t decode byte 0xc3</title>
		<link>http://www.semtexgirl.net/2009/07/30/unicodedecodeerror-ascii-codec-cant-decode-byte-0xc3/</link>
		<comments>http://www.semtexgirl.net/2009/07/30/unicodedecodeerror-ascii-codec-cant-decode-byte-0xc3/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 22:54:12 +0000</pubDate>
		<dc:creator>Andréia Bustamante</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.semtexgirl.net/?p=114</guid>
		<description><![CDATA[Problemas com unicode?
Vá no diretório &#60;python_home&#62;/lib/python2.6/site-packages/ e crie um novo arquivo com o nome sitecustomize.py com o conteúdo abaixo:
import sys
sys.setdefaultencoding('utf-8') 
Prontinho problema resolvido!
 Tweet este post]]></description>
			<content:encoded><![CDATA[<p>Problemas com unicode?</p>
<p>Vá no diretório &lt;python_home&gt;/lib/python2.6/site-packages/ e crie um novo arquivo com o nome sitecustomize.py com o conteúdo abaixo:</p>
<blockquote><p><code>import sys<br />
sys.setdefaultencoding('utf-8') </code></p></blockquote>
<p>Prontinho problema resolvido!</p>
<p id="tt_tweet" align="left"><a class="tt" href="http://twitter.com/home/?status=UnicodeDecodeError%3A+%27ascii%27+codec+can%27t+decode+byte+0xc3+http://bit.ly/a6Z56e" title="Post no twitter"><img class="img_tt" src="http://www.semtexgirl.net/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=UnicodeDecodeError%3A+%27ascii%27+codec+can%27t+decode+byte+0xc3+http://bit.ly/a6Z56e" title="Post no twitter">Tweet este post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.semtexgirl.net/2009/07/30/unicodedecodeerror-ascii-codec-cant-decode-byte-0xc3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compilando o PyActiveMQ + ActiveMQ-CPP no Mac OS X Leopard</title>
		<link>http://www.semtexgirl.net/2009/07/24/compilando-o-pyactivemq-activemq-cpp-no-mac-os-x-leopard/</link>
		<comments>http://www.semtexgirl.net/2009/07/24/compilando-o-pyactivemq-activemq-cpp-no-mac-os-x-leopard/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 02:56:51 +0000</pubDate>
		<dc:creator>Andréia Bustamante</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[ActiveMQ-CPP]]></category>
		<category><![CDATA[Boost]]></category>
		<category><![CDATA[Mac OS X Leopard]]></category>
		<category><![CDATA[PyActiveMQ]]></category>

		<guid isPermaLink="false">http://www.semtexgirl.net/?p=102</guid>
		<description><![CDATA[Finalmente consegui compilar o PyActiveMQ + ActiveMQ-CPP no meu Mac. Uma boa parte do trabalho eu fiz via Mac Port, vou colocar o passo-a-passo abaixo para caso alguem precise fazer o mesmo.
Pré-requistos:

 X11
Apple's Xcode Developer Tools
MacPorts 1.710
apr-util 1.3.8

update do will:
http://archive.apache.org/dist/apr/apr-1.3.8.tar.gz
http://archive.apache.org/dist/apr/apr-util-1.3.8.tar.gz
Para saber o que você ja tem instalado basta utilizar o comando abaixo:
sudo port installed
1) Atualizando [...]]]></description>
			<content:encoded><![CDATA[<p>Finalmente consegui compilar o PyActiveMQ + ActiveMQ-CPP no meu Mac. Uma boa parte do trabalho eu fiz via Mac Port, vou colocar o passo-a-passo abaixo para caso alguem precise fazer o mesmo.</p>
<p><strong>Pré-requistos:</strong></p>
<ul>
<li> X11</li>
<li>Apple's Xcode Developer Tools</li>
<li>MacPorts 1.710</li>
<li>apr-util 1.3.8</li>
</ul>
<p>update do will:</p>
<p><a title="apr-util-1.3.8" href="http://archive.apache.org/dist/apr/apr-1.3.8.tar.gz http://archive.apache.org/dist/apr/apr-util-1.3.8.tar.gz" target="_blank">http://archive.apache.org/dist/apr/apr-1.3.8.tar.gz</a><br />
<a href="http://archive.apache.org/dist/apr/apr-util-1.3.8.tar.gz" target="_blank">http://archive.apache.org/dist/apr/apr-util-1.3.8.tar.gz</a></p>
<p>Para saber o que você ja tem instalado basta utilizar o comando abaixo:</p>
<blockquote><p><code>sudo port installed</code></p></blockquote>
<p><strong>1)</strong> Atualizando o port:</p>
<blockquote><p><code>sudo port -v selfupdate</code></p></blockquote>
<p><strong>2)</strong> Instalando o python 2.6</p>
<blockquote><p><code>sudo port install python26<br />
sudo port install python_select<br />
sudo python_select python26</code></p></blockquote>
<p><strong>3)</strong> Instalando o Boost com suporte para o Python26</p>
<blockquote><p><code>sudo port install boost +python26</code></p></blockquote>
<p>Dica importante... este processo demora um bocado... portanto de um volta, tome um café, leia algum blog e por ai vai.</p>
<p><strong>4)</strong> Compilando o ActiveMQ-CPP</p>
<blockquote><p><code>svn co https://svn.apache.org/repos/asf/activemq/activemq-cpp/tags/activemq-cpp-2.2.6 activemq-cpp-2.2.6<br />
cd activemq-cpp-2.2.6<br />
./autogen.sh<br />
./configure --prefix=/opt/activemq-cpp<br />
make<br />
sudo make install<br />
</code></p></blockquote>
<p><strong>5)</strong> Compilando o PyActiveMQ</p>
<blockquote><p><code>svn co http://pyactivemq.googlecode.com/svn/tags/pyactivemq-0.1.0 pyactivemq-0.1.0<br />
cd pyactivemq-0.1.0<br />
</code></p></blockquote>
<p>Abra o arquivo setup.py e faça as seguintes alterações:<br />
de:</p>
<blockquote><p><code>libraries = [<br />
'libactivemq-cpp',<br />
'apr-1',<br />
'aprutil-1',<br />
'apriconv-1',<br />
'uuid',<br />
'ws2_32',<br />
'rpcrt4',<br />
'mswsock',<br />
'advapi32',<br />
'shell32'<br />
]<br />
</code></p></blockquote>
<p>para:</p>
<blockquote><p><code>libraries = [<br />
'libactivemq-cpp',<br />
'apr-1',<br />
'aprutil-1',<br />
'apriconv-1',<br />
#'uuid',<br />
'ws2_32',<br />
'rpcrt4',<br />
'mswsock',<br />
'advapi32',<br />
'shell32'<br />
]<br />
</code></p></blockquote>
<p>de:</p>
<blockquote><p><code>include_dirs = [<br />
'/opt/activemq-cpp-2.2.1/include/activemq-cpp-2.2.1'<br />
]<br />
libraries = [<br />
'activemq-cpp',<br />
'uuid',<br />
'boost_python'<br />
]<br />
extra_compile_args = []<br />
extra_link_args = [<br />
'-Wl,-rpath,/opt/activemq-cpp-2.2.1/lib'<br />
]<br />
</code></p></blockquote>
<p>para:</p>
<blockquote><p><code>include_dirs = [<br />
'/opt/activemq-cpp/include/activemq-cpp-2.2.6',<br />
'/opt/local/include'<br />
]<br />
libraries = [<br />
'activemq-cpp',<br />
#'uuid',<br />
'boost_python-mt'<br />
]<br />
library_dirs = [<br />
'/opt/activemq-cpp/lib'<br />
]<br />
extra_compile_args = []<br />
extra_link_args = [<br />
'-Wl,-rpath,/opt/activemq-cpp/lib'<br />
]<br />
</code></p></blockquote>
<p>python setup.py build<br />
sudo python setup.py install</p>
<p id="tt_tweet" align="left"><a class="tt" href="http://twitter.com/home/?status=Compilando+o+PyActiveMQ+%2B+ActiveMQ-CPP+no+Mac+OS+X+Leopard+http://bit.ly/aIZiZh" title="Post no twitter"><img class="img_tt" src="http://www.semtexgirl.net/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Compilando+o+PyActiveMQ+%2B+ActiveMQ-CPP+no+Mac+OS+X+Leopard+http://bit.ly/aIZiZh" title="Post no twitter">Tweet este post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.semtexgirl.net/2009/07/24/compilando-o-pyactivemq-activemq-cpp-no-mac-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Desejar trabalhar de forma ágil? Venha para a Globo.com!</title>
		<link>http://www.semtexgirl.net/2009/05/15/globocom-contrata/</link>
		<comments>http://www.semtexgirl.net/2009/05/15/globocom-contrata/#comments</comments>
		<pubDate>Fri, 15 May 2009 14:24:18 +0000</pubDate>
		<dc:creator>Andréia Bustamante</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[globo.com]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[contrata]]></category>

		<guid isPermaLink="false">http://www.semtexgirl.net/?p=88</guid>
		<description><![CDATA[A Globo.com continua crescendo, inovando e se transformando!
Devido a isso, estamos procurando por um Desenvolvedor (experiente e versátil) com sólidos conhecimentos teóricos de computação e capacidade de adaptação para integrar um de nossos times no GloboEsporte.com. Procuramos pessoas com espírito inovador, curiosidade, paixão por tecnologia e talento, que se empolgam com construir grandes softwares com [...]]]></description>
			<content:encoded><![CDATA[<p>A Globo.com continua crescendo, inovando e se transformando!</p>
<p>Devido a isso, estamos procurando por um Desenvolvedor (experiente e versátil) com sólidos conhecimentos teóricos de computação e capacidade de adaptação para integrar um de nossos times no GloboEsporte.com. Procuramos pessoas com espírito inovador, curiosidade, paixão por tecnologia e talento, que se empolgam com construir grandes softwares com grandes pessoas. Que acredite que ajudar a criar e distribuir um produto é importante. Nós também procuramos pessoas que pensam sobre o que nossos clientes gostariam de ter, que focam no sucesso do produto e do negócio e não se deixam levar em guerras religiosas sobre processos de desenvolvimento.</p>
<p>Hoje grande parte de nossos aplicativos são desenvolvidos em Java e Python, mas encorajamos o contato de desenvolvedores que dominem outras tecnologias de desenvolvimento web, pois apreciamos visões diferentes e diversidade de conhecimento e acreditamos que um bom desenvolvedor poderá estudar as tecnologias que utilizamos e dominá-las rapidamente.</p>
<p>Prezamos a colaboração e a constante busca pelo aperfeiçoamento.</p>
<p><strong>Nossos Desenvolvedores devem ser capazes de:</strong></p>
<ul>
<li>Trabalhar em equipe e ouvir a equipe;</li>
<li>Colocar suas idéias e valores de maneira clara e objetiva;</li>
<li>Expor suas opniões com segurança e baseadas em fundamentos;</li>
<li>Desenvolver módulos para integração com serviços web;</li>
<li>Projetar e programar a aplicação em camadas visando modularização;</li>
<li>Elaborar as melhores estratégias de implementação para reduzir o custo de manutenção do produto;</li>
<li>Aprimorar o ambiente de desenvolvimento automatizando processos repetitivos;</li>
<li>Estimar o tempo de desenvolvimento das atividades;</li>
<li>Dividir as atividades (Visões do Cliente) em tarefas;</li>
<li>Escolher as tarefas para desenvolvimento;</li>
<li>Atualizar o status de suas atividades diariamente;</li>
<li>Participar das reuniões de planejamento de iteração e release, reviews e retrospectivas com os demais integrantes do time, clientes e usuários;</li>
<li>Desenvolver os produtos de software;</li>
<li>Elaborar a arquitetura e esquema lógico dos dados quando necessário;</li>
<li>Implementar testes de unidade, aceitação, integração;</li>
<li>Trabalhar com ferramentas para Gerência de Configuração de Software (ex.: SVN, GIT e várias outras SCM suites);</li>
<li>Refatorar constantemente para manter o código limpo;</li>
<li>Integrar freqüentemente com o repositório porém sem descuidar de requisitos mínimos como executar os testes;</li>
<li>Revisar o código:
<ul>
<li>Trabalhar em par;</li>
<li>Outro desenvolvedor faz uma revisão antes da integração.<il></ul>
</li>
</ul>
<p><strong>É necessário ter experiência comprovada em:</strong></p>
<ul>
<li>Desenvolvimento multi-camadas usando tecnologias tais como EJB ou Hibernate;</li>
<li>Desenvolvimento de aplicações Java™ J2EE no ambiente da Web;</li>
<li>Implementação de testes unitários em JUnit e DBUnit;</li>
<li>Processos e Threads;</li>
<li>Redes;</li>
<li>Linguagens XML e SQL;</li>
<li>Ter sólidos conhecimentos de Engenharia de Software;</li>
<li>OO, MVC, Design Patterns;</li>
<li>Métodos e estratégias de depuração;</li>
<li>Um ou mais servidores de aplicação Java™: Tomcat, JBoss, Bea Weblogic e Jetty;</li>
<li>Bancos de dados: Oracle 9i/10g e MySQL.</li>
</ul>
<p><strong>É importante saber do que se trata e como funciona:</strong></p>
<ul>
<li>Subversion;</li>
<li>Git;</li>
<li>Test Driven Development (TDD);</li>
<li>SOA;</li>
<li>Web Services (SOAP, XML-RPC, REST);</li>
<li>Javascript, JQuery, Ajax, Template Engines;</li>
<li>CSS2, CSS3, HTML, DHTML e XSLT;</li>
<li>Scrum.</li>
</ul>
<p><strong>É desejável conhecer:</strong></p>
<ul>
<li>Linguagens de script (Shell Script, Perl...);</li>
<li>Linguagens dinâmicas, preferencialmente Python.</li>
</ul>
<p>Nós da Globo.com, buscamos criar o melhor ambiente possível, pois acreditamos que o segredo do sucesso de um time está nas pessoas e não nas ferramentas. Por isso, adotamos o Manifesto Ágil e quaisquer idéias que promovam a melhoria dos processos para o desenvolvimento de software. Oferecemos contratação apenas no regime CLT, com salário de mercado e um bom plano de benefícios. Nosso escritório fica localizado na Barra da Tijuca na cidade do Rio de Janeiro e damos suporte a pessoas de outros estados que queiram se mudar. Se você se sente capaz de encarar este desafio, envie seu currículo para andreia at corp dot globo dot com, com o valor pretendido e uma breve descrição do seu interesse pela oportunidade e sua aptidão.</p>
<p id="tt_tweet" align="left"><a class="tt" href="http://twitter.com/home/?status=Desejar+trabalhar+de+forma+%C3%A1gil%3F+Venha+para+a+Globo.com%21+http://bit.ly/bJ9vSy" title="Post no twitter"><img class="img_tt" src="http://www.semtexgirl.net/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Desejar+trabalhar+de+forma+%C3%A1gil%3F+Venha+para+a+Globo.com%21+http://bit.ly/bJ9vSy" title="Post no twitter">Tweet este post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.semtexgirl.net/2009/05/15/globocom-contrata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Software Development Best Practices 2008</title>
		<link>http://www.semtexgirl.net/2008/10/23/software-development-best-practices-2008/</link>
		<comments>http://www.semtexgirl.net/2008/10/23/software-development-best-practices-2008/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 16:05:54 +0000</pubDate>
		<dc:creator>Andréia Bustamante</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[globo.com]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[Best Practices]]></category>

		<guid isPermaLink="false">http://www.semtexgirl.net/?p=73</guid>
		<description><![CDATA[O <a href="http://sdbestpractices.com/">SD Best Practices</a> é uma conferência onde os principais players da comunidade de desenvolvimento de software se reúnem para aprender sobre as últimas tecnologias, e se encontram com os principais vendedores da indústria.]]></description>
			<content:encoded><![CDATA[<p>O <a href="http://sdbestpractices.com/">SD Best Practices</a> é uma conferência onde os principais players da comunidade de desenvolvimento de software se reúnem para aprender sobre as últimas tecnologias, e se encontram com os principais vendedores da indústria. A conferência é um treinamento centrado em fornecer as ferramentas necessárias para adoação com êxito em seus projetos das melhores práticas de design, qualidade e técnicas de gerenciamento de projeto.</p>
<p>Com uma programação com 142 sessões apresentadas em 6 formatos (Birds-of-a-Feather Gathering, Estudo de Caso, Classe, Experimental, Mesa Redonda, Tutorial) separados em 10 tracks( Algoritmos Avançados & Conceitos, Processo Ágil & Metodologia, C++, Design & Arquitetura, Linguagem & Implementação, Pessoas, Projetos & Times, Requisitos & Analise, Secure Design, Teste & Qualidade, Web Services/SOA) o SD Best Practices é uma maratona de 5 dias que começa na próxima segunda-feira, 27 de outubro e termina na sexta-feira dia 30 de outubro das 8:30 as 17:00</p>
<p>Solicitação aprovada, passagens compradas, hotel reservado, visto aprovado, agora é fato, Boston aqui vou eu!</p>
<p id="tt_tweet" align="left"><a class="tt" href="http://twitter.com/home/?status=Software+Development+Best+Practices+2008+http://bit.ly/cBT0CS" title="Post no twitter"><img class="img_tt" src="http://www.semtexgirl.net/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Software+Development+Best+Practices+2008+http://bit.ly/cBT0CS" title="Post no twitter">Tweet este post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.semtexgirl.net/2008/10/23/software-development-best-practices-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fotografia</title>
		<link>http://www.semtexgirl.net/2008/03/21/fotografia/</link>
		<comments>http://www.semtexgirl.net/2008/03/21/fotografia/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 03:30:48 +0000</pubDate>
		<dc:creator>Andréia Bustamante</dc:creator>
				<category><![CDATA[photography]]></category>

		<guid isPermaLink="false">http://www.semtexgirl.net/?p=66</guid>
		<description><![CDATA[Para quem ainda não sabe comecei a fazer o curso de fotografia da Escola Panamericana de Artes ;o), sendo assim acredito que devo voltar a escrever, porem o assunto provavelmente será este. Eu ainda continuo trabalhando com TI e tenho começado a usar scrum nos projetos que estou coordenando o que tem dado ótimos resultados, [...]]]></description>
			<content:encoded><![CDATA[<p>Para quem ainda não sabe comecei a fazer o curso de fotografia da Escola Panamericana de Artes ;o), sendo assim acredito que devo voltar a escrever, porem o assunto provavelmente será este. Eu ainda continuo trabalhando com TI e tenho começado a usar scrum nos projetos que estou coordenando o que tem dado ótimos resultados, mas nunca arrumo tempo pra escrever sobre isso ;o/</p>
<p>Bem, é isso ai pessoal!</p>
<p id="tt_tweet" align="left"><a class="tt" href="http://twitter.com/home/?status=Fotografia+http://bit.ly/cBdc1S" title="Post no twitter"><img class="img_tt" src="http://www.semtexgirl.net/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Fotografia+http://bit.ly/cBdc1S" title="Post no twitter">Tweet este post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.semtexgirl.net/2008/03/21/fotografia/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sobre gerenciamento de projetos</title>
		<link>http://www.semtexgirl.net/2007/02/23/sobre-gerenciamento-de-projetos/</link>
		<comments>http://www.semtexgirl.net/2007/02/23/sobre-gerenciamento-de-projetos/#comments</comments>
		<pubDate>Fri, 23 Feb 2007 20:45:27 +0000</pubDate>
		<dc:creator>Andréia Bustamante</dc:creator>
				<category><![CDATA[technical]]></category>

		<guid isPermaLink="false">http://www.semtexgirl.net/?p=64</guid>
		<description><![CDATA[Empresas americanas gastam mais de US$275 bilhões a cada ano em projetos de desenvolvimento de software aplicativo. Muitos desses projetos falharão, mas não por falta de dinheiro ou tecnologia; a maioria falhará por falta de um gerenciamento de projetos habilidoso.
 Tweet este post]]></description>
			<content:encoded><![CDATA[<p>Empresas americanas gastam mais de US$275 bilhões a cada ano em projetos de desenvolvimento de software aplicativo. Muitos desses projetos falharão, mas não por falta de dinheiro ou tecnologia; a maioria falhará por falta de um gerenciamento de projetos habilidoso.</p>
<p id="tt_tweet" align="left"><a class="tt" href="http://twitter.com/home/?status=Sobre+gerenciamento+de+projetos+http://bit.ly/bBsX4v" title="Post no twitter"><img class="img_tt" src="http://www.semtexgirl.net/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Sobre+gerenciamento+de+projetos+http://bit.ly/bBsX4v" title="Post no twitter">Tweet este post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.semtexgirl.net/2007/02/23/sobre-gerenciamento-de-projetos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aumentando o desempenho ao acessar arrays e os membros de um objeto</title>
		<link>http://www.semtexgirl.net/2007/01/10/aumentando-o-desempenho-ao-acessar-arrays-e-os-membros-de-um-objeto/</link>
		<comments>http://www.semtexgirl.net/2007/01/10/aumentando-o-desempenho-ao-acessar-arrays-e-os-membros-de-um-objeto/#comments</comments>
		<pubDate>Wed, 10 Jan 2007 12:35:17 +0000</pubDate>
		<dc:creator>Andréia Bustamante</dc:creator>
				<category><![CDATA[technical]]></category>

		<guid isPermaLink="false">http://www.semtexgirl.net/?p=63</guid>
		<description><![CDATA[Ao desenvolvermos uma aplicação em JNI o acesso aos membros de uma classe é normalmente realizado através das próprias funções JNI, em vez de permitir acesso direto aos membros nativos. Este procedimento tem uma vantagem e um inconveniente:
•	Vantagem: Os objetos apontados por referencias são visto de forma simples pelo programador.
•	Inconveniente: Impacto no desempenho
Este impacto no [...]]]></description>
			<content:encoded><![CDATA[<p>Ao desenvolvermos uma aplicação em JNI o acesso aos membros de uma classe é normalmente realizado através das próprias funções JNI, em vez de permitir acesso direto aos membros nativos. Este procedimento tem uma vantagem e um inconveniente:</p>
<p>•	Vantagem: Os objetos apontados por referencias são visto de forma simples pelo programador.<br />
•	Inconveniente: Impacto no desempenho</p>
<p>Este impacto no desempenho se vê atenuado com a utilização de métodos nativos apenas para realizar funções não triviais, é por este motivo que não costumamos usa-los para realizar operações triviais, exceto é claro em exemplos como neste artigo.</p>
<p><strong>Desempenho acessando arrays</strong></p>
<p>Quando trabalhamos com arrays múltiplos não é viável o uso de função para acessarmos cada elemento de um array, no intuito de resolver este problema foi desenvolvida uma solução chamada ‘pinning’, que consiste em um método nativo que pede a maquina virtual que não remova da memória o conteúdo de um array, desta forma o método nativo pode obter o ponteiro que aponta diretamente para o conteúdo de um array. Esta solução, entretanto, tem duas implicações:</p>
<p>•	O garbage coletor deve suportar ‘pinning’. Em muitas implementações é inviável utilizar ‘pinning’ pois complica o garbage coletor e induz �  fragmentação da memória.<br />
•	A máquina virtual deve posicionar as primitivas contiguamente na memória. Embora esta seja a disposição natural para array de tipos primitivos, os arrays booleanos podem ser implementados como empacotados e desempacotados. Uma disposição booleana empacotado usa um bit para cada elemento, visto que desempacotado usa tipicamente um byte para cada elemento. Conseqüentemente, o código nativo que confia na disposição exata dos arrays booleanos perdera sua portabilidade.</p>
<p>E através das funções do tipo Get<tipo>ArrayElements() podemos apenas obter ponteiros de tipo primitivos de dados, os arrays de objetos devem ser acessados individualmente usando GetObjectArrayElement().</p>
<p>Ainda assim Get<tipo>ArrayElements() não nos garante a obtenção do  ponteiro do array original uma vez que ele cria uma cópia em outra área de memória, em resumo esta decisão depende de:</p>
<p>Que o garbage colector suporte “pinning”, no qual implica que o objeto não pode ser liberado ainda que não seja uma referência Java e para que o JNI o libere é preciso executar a função Release<tipo>ArrayElements().</p>
<p>A distribuição dos elementos de um array na memória, assim como o seu tamanho sejam os mesmos do C.</p>
<p>De outra forma o array será copiado para outra área de memória e será formatado convenientemente.</p>
<p>Atento ao fato de que só quando chamamos a função Release<tipo>ArrayElements() que a máquina virtual finaliza o pinning,  deixando livre uma cópia do array.</p>
<p>Outra solução que foi incorporada ao JSDK 1.2 as funções GetPrimitiveArrayCritical() e ReleasePrimitiveArrayCritical(), ao uso destas funções são recomendadas sempre que uma thread não:</p>
<p>•	Possuir um processo de tempo indefinido<br />
•	Chamar outras funções JNI<br />
•	Realizar uma operação “thread sleep” (suspensão da execução da thread por um tempo determinado)</p>
<p>Cumprindo estas condições a máquina virtual pode desativar temporariamente o garbage colector enquanto o método nativo acessa diretamente o array, sem que a máquina virtual use pinning. Isto aumenta a possibilidade da máquina virtual retornar o array original em vez de uma cópia.</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* parametros.java */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Parametros <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">native</span> <span style="color: #993333;">int</span> soma<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> a, <span style="color: #993333;">int</span> b<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">native</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> texto<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> prompt<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">native</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> somaArrays<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> A, <span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> B<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		Parametros parametros = <span style="color: #000000; font-weight: bold;">new</span> Parametros<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;4+6=&quot;</span> + parametros.<span style="color: #006600;">soma</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4</span>, <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> string = parametros.<span style="color: #006600;">texto</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Digite algum texto&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;O texto digitado foi:&quot;</span> + string<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> A = <span style="color: #66cc66;">&#123;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">&#125;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> B = <span style="color: #66cc66;">&#123;</span> <span style="color: #cc66cc;">4</span>, <span style="color: #cc66cc;">5</span>, <span style="color: #cc66cc;">6</span> <span style="color: #66cc66;">&#125;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">int</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> C = parametros.<span style="color: #006600;">somaArrays</span><span style="color: #66cc66;">&#40;</span>A, B<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>C == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Não foi possível realizar a soma.&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;O resultado da soma dos arrays é:&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>; i &lt; C.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>C<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> + <span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">loadLibrary</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;parametros&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<blockquote><p>Listagem 13: Código da classe Parametros.java</p></blockquote>
<p>Implementação em C.</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* parametros.cpp */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JNIEXPORT jintArray JNICALL Java_Parametros_somaArrays<span style="color: #66cc66;">&#40;</span>JNIEnv* env,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">       jobject obj, jintArray arrayA, jintArray arrayB<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jintArray arrayC;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jint* A;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jint* B;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jint* C;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jsize i;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//Pegamos o tamanho de um dos arrays e comparamos</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jsize tamanho = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetArrayLength<span style="color: #66cc66;">&#40;</span>env,ArrayA<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>tamanho!=<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetArrayLength<span style="color: #66cc66;">&#40;</span>env,arrayB<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">NULL</span>; <span style="color: #808080; font-style: italic;">//tamanho dos arrays são diferentes.</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//criação do array de retorno</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	arrayC = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;NewIntArray<span style="color: #66cc66;">&#40;</span>env, tamanho<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	A = <span style="color: #66cc66;">&#40;</span>jint*<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetPrimitiveArrayCritical<span style="color: #66cc66;">&#40;</span>env, arrayA, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	B = <span style="color: #66cc66;">&#40;</span>jint*<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetPrimitiveArrayCritical<span style="color: #66cc66;">&#40;</span>env, arrayB, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	A = <span style="color: #66cc66;">&#40;</span>jint*<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetPrimitiveArrayCritical<span style="color: #66cc66;">&#40;</span>env, arrayC, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i &lt; tamanho; i++<span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		C<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = A<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>+B<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;ReleasePrimitiveArrayCritical<span style="color: #66cc66;">&#40;</span>env, ArrayA,A, JNI_ABORT<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;ReleasePrimitiveArrayCritical<span style="color: #66cc66;">&#40;</span>env, ArrayB,B, JNI_ABORT<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;ReleasePrimitiveArrayCritical<span style="color: #66cc66;">&#40;</span>env, ArrayA,A, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">return</span> C;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<blockquote><p>Listagem 14: Código nativo parametros.cpp</p></blockquote>
<p>Por ultimo devo dizer que JNI garante o acesso concorrente ao array por várias threads, uma vez que o JNI mantém um controlador de pinnings, para que uma thread não finalize o pinning de um array que outra thread esta usando.</p>
<p><strong>Desempenho ao acessar os membros de um objeto</strong></p>
<p>Para obtermos o fieldID ou o methodID realizamos uma busca simbólica em uma base de nomes dos membros, o que é relativamente custoso. Uma forma de diminuir este custo quando houver necessidade de se busca-los mais de uma vez é cachear-los.</p>
<p>Para cachear podemos usar duas técnicas:</p>
<p><strong>1.</strong>Cachear em variáveis estáticas de uma função nativa, como por exemplo a função abaixo:</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JNIEXPORT <span style="color: #993333;">void</span> JNICALL Java_MyClass_accessField<span style="color: #66cc66;">&#40;</span>JNIEnv *env, jobject obj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">static</span> jfieldID fid_s = <span style="color: #000000; font-weight: bold;">NULL</span>; <span style="color: #808080; font-style: italic;">/* cacheando field ID para s */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		jclass cls = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetObjectClass<span style="color: #66cc66;">&#40;</span>env, obj<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		jstring jstr;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #993333;">const</span> <span style="color: #993333;">char</span> *str;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>fid_s == <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			fid_s = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetFieldID<span style="color: #66cc66;">&#40;</span>env, cls, <span style="color: #ff0000;">&quot;s&quot;</span>,<span style="color: #ff0000;">&quot;Ljava/lang/String;&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>fid_s == <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">				<span style="color: #b1b100;">return</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Aplicação em C:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		jstr = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetObjectField<span style="color: #66cc66;">&#40;</span>env, obj, fid_s<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		str = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetStringUTFChars<span style="color: #66cc66;">&#40;</span>env, jstr, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>str == <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #b1b100;">return</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot; c.s = <span style="color: #000099; font-weight: bold;">\&quot;</span>%s<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, str<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;ReleaseStringUTFChars<span style="color: #66cc66;">&#40;</span>env, jstr, str<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		jstr = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;NewStringUTF<span style="color: #66cc66;">&#40;</span>env, <span style="color: #ff0000;">&quot;123&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>jstr == <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #b1b100;">return</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;SetObjectField<span style="color: #66cc66;">&#40;</span>env, obj, fid_s, jstr<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li></ol></pre>
<blockquote><p>Listagem 15: Código nativo para cache em variáveis estáticas </p></blockquote>
<p><strong>2.</strong>Cachear ao inicializar uma classe, isso quer dizer que em um bloco estático podemos chamar uma função que inicializa todos os atributos e métodos que vamos precisar.</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyClass <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">native</span> <span style="color: #993333;">void</span> initIDs<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">native</span> <span style="color: #993333;">void</span> nativeMethod<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">void</span> callback<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Aplicação Java&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		MyClass call = <span style="color: #000000; font-weight: bold;">new</span> MyClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		call.<span style="color: #006600;">nativeMethod</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">static</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">loadLibrary</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myclass&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		initIDs<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<blockquote><p>Listagem 16: Código da classe MyClass, cache ao inicializar a classe.</p></blockquote>
<p>Implementação em C.</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">jmethodID MID_MyClass_callback;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JNIEXPORT <span style="color: #993333;">void</span> JNICALL Java_MyClass_initIDs<span style="color: #66cc66;">&#40;</span>JNIEnv *env, jclass cls<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	MID_ MyClass_callback = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetMethodID<span style="color: #66cc66;">&#40;</span>env, cls, <span style="color: #ff0000;">&quot;callback&quot;</span>, <span style="color: #ff0000;">&quot;()V&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JNIEXPORT <span style="color: #993333;">void</span> JNICALL Java_ MyClass_nativeMethod<span style="color: #66cc66;">&#40;</span>JNIEnv *env, jobject obj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Aplicação C<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;CallVoidMethod<span style="color: #66cc66;">&#40;</span>env, obj,MID_MyClass_callback<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<blockquote><p>Listagem 17: Código nativo que implementa o cache na inicialização da classe</p></blockquote>
<p>E logo initIDs() guarda os IDs em variáveis globais.<br />
Das duas técnicas a mais recomendada é a segunda por varias razões:</p>
<p><strong>1.</strong>Os IDs se tornam  inválidos logo que a classe é descarregada. Conforme o class loader descarrega a classe e ao se carregar a classe não se atualizam os IDs, na primeira solução porem o mesmo não acontece.</p>
<p><strong>2.</strong>É relativamente mais rápido uma vez que carregados os IDs não teremos que voltar a comprovar o valor do ID com:</p>
<pre>if (fid_s == NULL) {}</pre>
<p><strong>Diferenças de custo entre os objetos nativos e os métodos Java</strong></p>
<p>Neste tópico vamos comentar rapidamente qual o custo de se realizar uma chamada Java-nativo, nativo-Java (chamada callback), comparado com uma chamada java-java.</p>
<p>Uma chamada Java-nativo é mais lenta que uma chamada java-java porque:</p>
<p><strong>1.</strong>A máquina virtual tem que liberar as referências locais pra depois chamar o método nativo.<br />
<strong>2.</strong>A máquina virtual tem que buscar uma função dinâmica em sua biblioteca.<br />
<strong>3.</strong>A máquina virtual muitas vezes pode chamar in-line quando um método Java chama outro método Java.</p>
<p>Estima-se que o custo é de duas a três vezes superior ao de uma chamada java-java.<br />
Estima-se também que o custo de uma chamada nativo-Java (callback) é duas ou três vezes superior a uma chamada Java-Java. O principal custo agregado esta em:</p>
<p><strong>1.</strong>Obtenção do fieldID e do methodID<br />
<strong>2.</strong>E no acesso aos atributos através de funções, enquanto que a virtual machine pode acessá-los diretamente.</p>
<blockquote><p>
<strong>Para Saber Mais</strong><br />
Indicado pela Sun como fonte definitiva de informações sobre JNI.<br />
LIANG, Sheng. The Java Native Interface - Programmers Guide and Specification.<br />
Massachusetts: ADDISON-WESLEY, 1999. ISBN 0-201-32577-2.<br />
Pode ser baixado em:</p>
<p>http://java.sun.com/docs/books/jni/download/jni.pdf</p>
</blockquote>
<p><strong>Considerações Finais</strong></p>
<p>Neste artigo apresentamos uma visão geral de como se escrever aplicações híbridas envolvendo Java, JNI e bibliotecas dinâmicas nativas criadas a partir de código C. Abordamos algumas técnicas que podem ser utilizadas para facilitar a integração de sistemas legados. E, ainda uma breve visão de custo e melhoria de desempenho.</p>
<p>Como podemos perceber o JNI é uma ferramenta poderosa, contudo, é preciso estar ciente que uma aplicação Java chamando código nativo compromete a portabilidade e a segurança da aplicação. Pois, embora o bytecode Java compilado permaneça altamente portável, o código nativo deve ser recompilado para cada plataforma na qual se pretenda executar a aplicação.</p>
<p><strong>Referencias</strong></p>
<p>LIANG, Sheng. The Java Native Interface - Programmers Guide and Specification.<br />
Massachusetts: ADDISON-WESLEY, 1999. ISBN 0-201-32577-2.</p>
<p>LINDHOLM, Tim;YELLIN, Frank. Java The JavaTM Virtual Machine Specification.<br />
1999. Ultimo acesso em 17 de Julho de 2006. Disponível em:<br />
< http://java.sun.com/docs/books/vmspec/2nd-edition/html/VMSpecTOC.doc.html></p>
<p>MEAD, Matthew. Programmming in C/C++ with the Java Native Interface.<br />
1998. Ultimo acesso em 17 de Julho de 2006. Disponível em:<br />
< http://www.pacifier.com/~mmead/jni/cs510jip/index.html >.</p>
<p>SUN MICROSYSTEMS. Java Native Interface Specification.<br />
2003. Ultimo acesso em 17 de Julho de 2006. Disponível em:<br />
<http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/jniTOC.html></p>
<p>SUN MICROSYSTEMS. javap - The Java Class File Disassembler.<br />
2002. Ultimo acesso em 17 de Julho de 2006. Disponível em:<br />
< http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javap.html></p>
<p>SUN MICROSYSTEMS. javah - C Header and Stub File Generator.<br />
2002. Ultimo acesso em 17 de Julho de 2006. Disponível em:<br />
< http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javah.html></p>
<p id="tt_tweet" align="left"><a class="tt" href="http://twitter.com/home/?status=Aumentando+o+desempenho+ao+acessar+arrays+e+os+membros+de+um+objeto+http://bit.ly/9tP4Ou" title="Post no twitter"><img class="img_tt" src="http://www.semtexgirl.net/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Aumentando+o+desempenho+ao+acessar+arrays+e+os+membros+de+um+objeto+http://bit.ly/9tP4Ou" title="Post no twitter">Tweet este post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.semtexgirl.net/2007/01/10/aumentando-o-desempenho-ao-acessar-arrays-e-os-membros-de-um-objeto/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Acessando os métodos de um objeto</title>
		<link>http://www.semtexgirl.net/2007/01/09/acessando-os-metodos-de-um-objeto/</link>
		<comments>http://www.semtexgirl.net/2007/01/09/acessando-os-metodos-de-um-objeto/#comments</comments>
		<pubDate>Tue, 09 Jan 2007 18:31:15 +0000</pubDate>
		<dc:creator>Andréia Bustamante</dc:creator>
				<category><![CDATA[technical]]></category>

		<guid isPermaLink="false">http://www.semtexgirl.net/?p=61</guid>
		<description><![CDATA[Com JNI alem de podermos acessar os atributos de um objeto Java podemos também acessar seus métodos, este acesso é conhecido como callback, pois o Java executa um método nativo e em seguida o método nativo executa um método Java.
Figura 2: Estrutura de Callback
Existem três tipos de métodos Java:
•	Métodos de instancia
•	Métodos de classe
•	Construtores
Vamos abordar o [...]]]></description>
			<content:encoded><![CDATA[<p>Com JNI alem de podermos acessar os atributos de um objeto Java podemos também acessar seus métodos, este acesso é conhecido como callback, pois o Java executa um método nativo e em seguida o método nativo executa um método Java.</p>
<blockquote><p><center><img src="http://www.semtexgirl.net/wp-content/uploads/2007/01/callback1.JPG" alt="" />Figura 2: Estrutura de Callback</center></p></blockquote>
<p>Existem três tipos de métodos Java:<br />
•	Métodos de instancia<br />
•	Métodos de classe<br />
•	Construtores</p>
<p>Vamos abordar o procedimento a ser realizado em cada caso.</p>
<p><strong>Acessando métodos de instancia</strong></p>
<p>O acesso aos métodos de uma classe é extremamente parecido com o acesso aos atributos e para acessá-los também é preciso seguir dois passos:</p>
<p><strong>1.</strong>O primeiro passo é obter o methodID do método usando a função:</p>
<p><strong>GetStaticMethodID</strong><br />
Protótipo</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">jmethodID GetStaticMethodID<span style="color: #66cc66;">&#40;</span>JNIEnv *env,jclass clazz, <span style="color: #000000; font-weight: bold;">const</span> <span style="color: #993333;">char</span> *name,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">const</span> <span style="color: #993333;">char</span> *sig<span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p><strong>2.</strong>E em seguida usamos as funções:</p>
<p><strong>Call<tipo>Method</strong><br />
Protótipo:</p>
<pre class="java">&lt;tipoNativo&gt; Call&lt;tipo&gt;Method<span style="color: #66cc66;">&#40;</span>JNIEnv *env,jobject obj,
jmethodID methodID, ...<span style="color: #66cc66;">&#41;</span>;</pre>
<table width="327" height="190" border="1" cellpadding="1" cellspacing="0" bordercolor="#333333">
<tr bordercolor="#333333" bgcolor="#666666">
<td><font color="#FFFFFF"><strong>Call&lt;Tipo&gt;Method </strong></font></td>
<td><font color="#FFFFFF"><strong>&lt;TipoNativo&gt; </strong></font></td>
</tr>
<tr>
<td>CallVoidMethodV </td>
<td>void </td>
</tr>
<tr>
<td>CallObjectMethodV </td>
<td>Jobject </td>
</tr>
<tr>
<td>CallBooleanMethodV </td>
<td>Jboolean </td>
</tr>
<tr>
<td>CallByteMethodV </td>
<td>Jbyte </td>
</tr>
<tr>
<td>CallCharMethodV </td>
<td>Jchar </td>
</tr>
<tr>
<td>CallShortMethodV </td>
<td>Jshort </td>
</tr>
<tr>
<td>CallIntMethodV </td>
<td>Jint </td>
</tr>
<tr>
<td>CallLongMethodV </td>
<td>Jlong </td>
</tr>
<tr>
<td>CallFloatMethodV </td>
<td>Jfloat </td>
</tr>
<tr>
<td>CallDoubleMethodV </td>
<td>Jdouble </td>
</tr>
</table>
<p>Devemos usar a função de acordo com o tipo retornado. Os parâmetros são passados por uma lista de parâmetros variáveis que esta no final da função (...)</p>
<p>CallObjectMethod() é usado tanto para métodos que retornam objetos como para métodos que retornam arrays,  para os métodos que retornam tipos primitivos devemos usar a função correspondente de acordo com a tabela acima.<br />
Como exemplo, na listagem 7, faremos um método nativo chamado somaC() que chama um método Java chamado somaJava(), conforme listagem 6.</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Contador <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">int</span> atributo = <span style="color: #cc66cc;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">native</span> <span style="color: #993333;">void</span> incrementa<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">int</span> somaJava<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> a, <span style="color: #993333;">int</span> b<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">return</span> a + b;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">native</span> <span style="color: #993333;">void</span> somaC<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		Contador contador = <span style="color: #000000; font-weight: bold;">new</span> Contador<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Antes de chamar o método incrementa()</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">                  o atributo vale:&quot;</span>+contador.<span style="color: #006600;">atributo</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		contador.<span style="color: #006600;">incrementa</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Depois de chamar o método incrementa()</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">                 o atributo vale:&quot;</span>+contador.<span style="color: #006600;">atributo</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		contador.<span style="color: #006600;">somaC</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">loadLibrary</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;contador&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<blockquote><p>Listagem 6:  Contador.java, implementação do método somaJava()</p></blockquote>
<p>E a implementação da função nativa correspondente:</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* contador.cpp */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #66cc66;">&#40;</span>...<span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JNIEXPORT <span style="color: #993333;">void</span> JNICALL Java_Contador_somaC<span style="color: #66cc66;">&#40;</span>JNIEnv *env, jobject obj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #993333;">int</span> a=<span style="color: #cc66cc;">5</span>,b=<span style="color: #cc66cc;">4</span>,c;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//Obter o methodID</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jclass class = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;FindClass<span style="color: #66cc66;">&#40;</span>env,<span style="color: #ff0000;">&quot;Contador&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jmethodID methodID = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetMethodID<span style="color: #66cc66;">&#40;</span>env, class, <span style="color: #ff0000;">&quot;somaJava&quot;</span>, <span style="color: #ff0000;">&quot;(II)I&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//Executando o metodo</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	c=<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;CallIntMethod<span style="color: #66cc66;">&#40;</span>env, obj, methodID, a,b<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li></ol></pre>
<blockquote><p>Listagem 7: Contador.cpp, implementação da função somaC()</p></blockquote>
<p><strong>Acessando métodos de classe</strong></p>
<p>O processo é similar ao de execução de método de instancia, só que agora usamos outras funções.</p>
<p><strong>1.</strong>Para obter o methodID usamos:<br />
<strong>GetStaticMethodID</strong><br />
Protótipo:</p>
<pre class="java">jmethodID GetStaticMethodID<span style="color: #66cc66;">&#40;</span>JNIEnv *env, jclass clazz, <span style="color: #000000; font-weight: bold;">const</span> <span style="color: #993333;">char</span> *name,
<span style="color: #000000; font-weight: bold;">const</span> <span style="color: #993333;">char</span> *sig<span style="color: #66cc66;">&#41;</span>;</pre>
<p><strong>2.</strong>Para executar os métodos usamos:<br />
<strong>CallStatic<tipo>MethodV</strong><br />
Protótipo:</p>
<pre class="java">&lt;tipoNativo&gt; CallStatic&lt;tipo&gt;MethodV<span style="color: #66cc66;">&#40;</span>JNIEnv *env, jclass clazz,
jmethodID methodID, va_list args<span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<table width="327" height="190" border="1" cellpadding="1" cellspacing="0" bordercolor="#333333">
<tr bordercolor="#333333" bgcolor="#666666">
<td><font color="#FFFFFF"><strong>CallStatic&lt;Tipo&gt;Method </strong></font></td>
<td><font color="#FFFFFF"><strong>&lt;TipoNativo&gt; </strong></font></td>
</tr>
<tr>
<td>CallStaticVoidMethodV </td>
<td>void </td>
</tr>
<tr>
<td>CallStaticObjectMethodV </td>
<td>Jobject </td>
</tr>
<tr>
<td>CallStaticBooleanMethodV </td>
<td>Jboolean </td>
</tr>
<tr>
<td>CallStaticByteMethodV </td>
<td>Jbyte </td>
</tr>
<tr>
<td>CallStaticCharMethodV </td>
<td>Jchar </td>
</tr>
<tr>
<td>CallStaticShortMethodV </td>
<td>Jshort </td>
</tr>
<tr>
<td>CallStaticIntMethodV </td>
<td>Jint </td>
</tr>
<tr>
<td>CallStaticLongMethodV </td>
<td>Jlong </td>
</tr>
<tr>
<td>CallStaticFloatMethodV </td>
<td>Jfloat </td>
</tr>
<tr>
<td>CallStaticDoubleMethodV </td>
<td>Jdouble </td>
</tr>
</table>
<p>Que são idênticas as executadas pelos métodos de instância, porem recebem como parâmetro um jclass em vez de um jobject.</p>
<p><strong>Acessando métodos de instancia de uma superclasse</strong></p>
<p>Em JNI podemos obter a classe base de uma classe usando:</p>
<pre class="java">Jclass GetSuperClass<span style="color: #66cc66;">&#40;</span>HNIEnv* env, jclass <span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>Esta função retorna uma classe ou NULL se a classe for um java.lang.Object ou uma interface.</p>
<p>Se executarmos um método que foi redefinido sobre uma referencia do tipo base usando as funções Call<tipo>Method() estaremos na verdade executando o método derivado, já que o Java usa ligação dinâmica.</p>
<p>Para executar um método de base teremos que usar as funções:</p>
<p><strong>CallNonvirtual<tipo>MethodV</strong></p>
<p>Protótipo:</p>
<pre class="java">&lt;nativeType&gt; CallNonvirtual&lt;type&gt;MethodV<span style="color: #66cc66;">&#40;</span>JNIEnv *env, jobject obj, jclass clazz,
jmethodID methodID, va_list args<span style="color: #66cc66;">&#41;</span>;</pre>
<table width="327" height="190" border="1" cellpadding="1" cellspacing="0" bordercolor="#333333">
<tr bordercolor="#333333" bgcolor="#666666">
<td><font color="#FFFFFF"><strong>CallNonvirtual&lt;Tipo&gt;Method </strong></font></td>
<td><font color="#FFFFFF"><strong>&lt;TipoNativo&gt; </strong></font></td>
</tr>
<tr>
<td>CallNonvirtualVoidMethodV </td>
<td>void </td>
</tr>
<tr>
<td>CallNonvirtualObjectMethodV </td>
<td>Jobject </td>
</tr>
<tr>
<td>CallNonvirtualBooleanMethodV </td>
<td>Jboolean </td>
</tr>
<tr>
<td>CallNonvirtualByteMethodV </td>
<td>Jbyte </td>
</tr>
<tr>
<td>CallNonvirtualCharMethodV </td>
<td>Jchar </td>
</tr>
<tr>
<td>CallNonvirtualShortMethodV </td>
<td>Jshort </td>
</tr>
<tr>
<td>CallNonvirtualIntMethodV </td>
<td>Jint </td>
</tr>
<tr>
<td>CallNonvirtualLongMethodV </td>
<td>Jlong </td>
</tr>
<tr>
<td>CallNonvirtualFloatMethodV </td>
<td>Jfloat </td>
</tr>
<tr>
<td>CallNonvirtualDoubleMethodV </td>
<td>Jdouble </td>
</tr>
</table>
<p>Observe o exemplo das classes Java das listagens 8 e 9 e a implementação das funções nativas na listagem 10.</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Base.java */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Base <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a>  metodoJava<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #ff0000;">&quot;Base&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">native</span> <span style="color: #993333;">void</span> metodoC<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		Base base = <span style="color: #000000; font-weight: bold;">new</span> Derivada<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		base.<span style="color: #006600;">metodoC</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">static</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">loadLibrary</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Base&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li></ol></pre>
<blockquote><p>Listagem 8: Código da classe Base</p></blockquote>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Derivada.java */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Derivada <span style="color: #000000; font-weight: bold;">extends</span> Base<span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> metodoJava<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #ff0000;">&quot;Derivada&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li></ol></pre>
<blockquote><p>Listagem 9: Código da classe Derivada</p></blockquote>
<p>Observe que metodoJava() foi redefinido. Vamos provar chamando o objeto do tipo Derivada, usando a função CallObjectMethod() e CallNonvirtualObjectMethod().</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* base.cpp */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#40;</span>...<span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JNIEXPORT <span style="color: #993333;">void</span> JNICALL Java_Base_metodoC<span style="color: #66cc66;">&#40;</span>JNIEnv* env, jobject object<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//Primeiro passo obter o methodID da classe Base</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jclass class = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;FindClass<span style="color: #66cc66;">&#40;</span>env,<span style="color: #ff0000;">&quot;Base&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jmethodID methodID = <span style="color: #66cc66;">&#40;</span>env*<span style="color: #66cc66;">&#41;</span>-&gt;GetMethodID<span style="color: #66cc66;">&#40;</span>env, class, <span style="color: #ff0000;">&quot;metodoJava&quot;</span>,<span style="color: #ff0000;">&quot;()Ljava/lang/String;&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//Agora executamos o metodo sobre o object que é uma referencia do tipo Base</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #808080; font-style: italic;">//que aponta para um objeto Derivada e executa o metodo Derivada</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jstring mensagem=<span style="color: #66cc66;">&#40;</span>jstring<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;CallObjectMethod<span style="color: #66cc66;">&#40;</span>env, object, methodID<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #993333;">const</span> jbyte* mensagem_c = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetStringUTFChars<span style="color: #66cc66;">&#40;</span>env, mensagem, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;A mensagem do metodoJava() é :%s&quot;</span>, mensagem_c<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;ReleaseStringUTFChars<span style="color: #66cc66;">&#40;</span>env,mensagem, mensagem_c<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #808080; font-style: italic;">//Agora vamos executar o método da Base</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	mensagem = <span style="color: #66cc66;">&#40;</span>jstring<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;CallNonvirtualObjectMethod<span style="color: #66cc66;">&#40;</span>env, object,class, methodID<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	mensagem_c = <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;GetStringUTFChars<span style="color: #66cc66;">&#40;</span>env, mensagem, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;A mensagem do metodoJava() é :%s&quot;</span>, mensagem_c<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;ReleaseStringUTFChars<span style="color: #66cc66;">&#40;</span>env,mensagem, mensagem_c<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li></ol></pre>
<blockquote><p>Listagem 10: Implementação da função nativa, que executa o método da classe Base</p></blockquote>
<p>Obteremos como saída</p>
<blockquote><p>A mensagem do metodoJava() é: Derivada<br />
A mensagem do metodoJava() é: Base
</p></blockquote>
<p>Observe que é similar ao uso de super em Java, porem não é igual, pois em Java o super permite chamar os métodos de uma classe imediatamente da base, enquanto que com CallNonvirtual<tipo>Method() podemos executar os métodos de qualquer base.</p>
<p>Ex.: se temos:</p>
<blockquote><p><center><img src="http://www.semtexgirl.net/wp-content/uploads/2007/01/derivada1.JPG" alt="" /><br />
Figura 3: Exemplo de hierarquia de classe</center></p></blockquote>
<p>Tanto em JNI como em Java podemos chamar a partir de B os métodos de A, porem a partir de C não podemos executar os métodos de A usando super porem, podemos fazê-lo usando JNI.</p>
<p>Outra diferença é que podemos executar os métodos da classe base fora do objeto, coisa que não é possível fazer em Java usando super.</p>
<p>Resumindo em Java não podemos fazer:</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">A a = <span style="color: #000000; font-weight: bold;">new</span> B<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">a.<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">metodo</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p><strong>Acessando um construtor</strong></p>
<p>Acessar um construtor em JNI é igual ao acesso a qualquer outro método de instância a única diferença é que para acessarmos o construtor usamos “<init>” como sendo o nome do método.<br />
E uma vez que tenhamos o methodID do construtor podemos passa-lo para a função:<br />
<strong>NewObject</strong><br />
Protótipo:</p>
<pre class="java">jobject NewObject<span style="color: #66cc66;">&#40;</span>JNIEnv *env, jclass clazz,jmethodID methodID, ...<span style="color: #66cc66;">&#41;</span>;</pre>
<p>Que instância o objeto e executa o construtor especificado.</p>
<p>Existe outra forma de criar objetos Java, que consiste em usar a seguinte função:</p>
<p><strong>AllocObject</strong><br />
Protótipo:</p>
<pre class="java">jobject AllocObject<span style="color: #66cc66;">&#40;</span>JNIEnv *env, jclass clazz<span style="color: #66cc66;">&#41;</span>;</pre>
<p>Esta função cria um objeto sem iniciá-lo e em seguida usa-se uma função CallNovirtual<tipo>Method() para executar o construtor do objeto desejado.</p>
<p>Esta é uma forma menos elegante, pois obteríamos o objeto sem iniciá-lo e não poderíamos esquecer de chamar CallNovirtual<tipo>Method() e depois cria-lo com AllocObject().</p>
<p>Como exemplo na listagem 11, vamos fazer um método nativo que cria um objeto Ponto e o retorna com os valores passados como parâmetros ao método nativo.</p>
<pre class="java"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Ponto.java */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Ponto <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">int</span> x;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">int</span> y;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> Ponto<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> x, <span style="color: #993333;">int</span> y<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">x</span> = x;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">y</span> = y;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	@Override</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> toString<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #ff0000;">&quot;[&quot;</span>+x+<span style="color: #ff0000;">&quot;,&quot;</span>+y+<span style="color: #ff0000;">&quot;]&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">native</span> Ponto criaPonto1<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> x, <span style="color: #993333;">int</span> y<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">native</span> Ponto criaPonto2<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> x, <span style="color: #993333;">int</span> y<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>criaPonto1<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>criaPonto2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #000000; font-weight: bold;">static</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">loadLibrary</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ponto&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Listagem 11: Código da classe Ponto.java</p>
<p>Agora, na listagem 12, vamos implementá-lo com NewObject() e também com AllocObject().</p>
<pre class="c"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* ponto.cpp */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JNIEXPORT <span style="color: #993333;">void</span> JNICALL Java_PontocriaPonto1<span style="color: #66cc66;">&#40;</span>JNIEnv* env, jclass class, jint x, jint y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jmethodID methodID = <span style="color: #66cc66;">&#40;</span>env*<span style="color: #66cc66;">&#41;</span>-&gt;GetMethodID<span style="color: #66cc66;">&#40;</span>env, class,<span style="color: #ff0000;">&quot;&lt;init&gt;&quot;</span>,<span style="color: #ff0000;">&quot;(II)V&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>jmethodID==<span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">NULL</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;NewObject<span style="color: #66cc66;">&#40;</span>env,class,<span style="color: #ff0000;">&quot;&lt;init&gt;&quot;</span>,<span style="color: #ff0000;">&quot;(II)V&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">JNIEXPORT <span style="color: #993333;">void</span> JNICALL Java_PontocriaPonto2<span style="color: #66cc66;">&#40;</span>JNIEnv* env, jclass class, jint x, jint y<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jobject obj;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	jmethodID methodID = <span style="color: #66cc66;">&#40;</span>env*<span style="color: #66cc66;">&#41;</span>-&gt;GetMethodID<span style="color: #66cc66;">&#40;</span>env, class,<span style="color: #ff0000;">&quot;&lt;init&gt;&quot;</span>,<span style="color: #ff0000;">&quot;(II)V&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>jmethodID==<span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">		<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">NULL</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	obj = <span style="color: #66cc66;">&#40;</span>*en<span style="color: #66cc66;">&#41;</span>-&gt;AllocObject<span style="color: #66cc66;">&#40;</span>env,class<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #66cc66;">&#40;</span>*env<span style="color: #66cc66;">&#41;</span>-&gt;CallNonvirtualVoidMethod<span style="color: #66cc66;">&#40;</span>env,obj,class, methodID,x,y<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #b1b100;">return</span> obj;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<blockquote><p>Listagem 12: Código nativo ponto.cpp</p></blockquote>
<p id="tt_tweet" align="left"><a class="tt" href="http://twitter.com/home/?status=Acessando+os+m%C3%A9todos+de+um+objeto+http://bit.ly/aB9M3K" title="Post no twitter"><img class="img_tt" src="http://www.semtexgirl.net/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Acessando+os+m%C3%A9todos+de+um+objeto+http://bit.ly/aB9M3K" title="Post no twitter">Tweet este post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.semtexgirl.net/2007/01/09/acessando-os-metodos-de-um-objeto/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
