<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Antonio,</div><div><br>By compiled java type I mean a class when you don't have the sources and therefore you can't modify its structure (like java.lang.String). I believe that most of the visitors could use JavaSource instead.</div><div><br></div><div>As I beforementioned, Roaster still does not support this feature(parsing compiled classes), so I can't tell in terms of performance which one is faster.<br><br></div><div><br>Em 14/03/2015, às 06:41, Antonio Goncalves &lt;<a href="mailto:antonio.mailing@gmail.com">antonio.mailing@gmail.com</a>&gt; escreveu:<br><br></div><blockquote type="cite"><div><div dir="ltr">What do you mean by "<span style="font-size:12.8000001907349px">compiled java type" ? Something like java.lang.String because it's in the rt.jar and you don't have the sources ? Because most of the visitors "visit our code" (i.e. the code in the project we are generating to with Forge). So that would mean that most of the visistors should then use JavaSource ?&nbsp;</span><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">And in terms of performance, is there a difference ? Is it "faster" to parse source code rather then byte code ?&nbsp;</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><div><span style="font-size:12.8000001907349px">Antonio</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-03-13 23:16 GMT+01:00 George Gastaldi <span dir="ltr">&lt;<a href="mailto:ggastald@redhat.com" target="_blank">ggastald@redhat.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>IMHO, there is a minor difference that may explain it. JavaType should be used when the object might be a compiled java type vs when you have the source code of a Java type (JavaSource). In practice they don't differ much but afaik this was the main difference.</div><div><br></div><div>PS: Roaster does not support parsing of compiled java types yet, but the model is ready for this feature when it becomes available.<br><br><br></div><div><br>Em 13/03/2015, às 18:19, Antonio Goncalves &lt;<a href="mailto:antonio.mailing@gmail.com" target="_blank">antonio.mailing@gmail.com</a>&gt; escreveu:<br><br></div><div><div class="h5"><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div><div>Hi all,</div><div><br></div><div>I am having a look at some code and realize that I don't understand the subtle difference between <font face="monospace, monospace">JavaType</font> and <font face="monospace, monospace">JavaSource</font>&nbsp;in certain cases. In some visitor code (see below), I see :</div><div><br></div><div><font face="monospace, monospace">JavaType&lt;?&gt; javaType = resource.getJavaType();<br></font></div><div><br></div><div>And other times I see :</div><div><br></div><div><font face="monospace, monospace">JavaSource&lt;?&gt; javaSource = javaResource.getJavaType();<br></font></div><div><br></div><div>So I look at the code. <font face="monospace, monospace">JavaSource</font> extends from <font face="monospace, monospace">JavaType</font>, adds one method, and then they both implement similar interfaces (<font face="monospace, monospace">JavaDocCapable</font> vs <font face="monospace, monospace">JavaDocCapableSource</font>).</div><div><br></div><div>So, in the following example, why use <font face="monospace, monospace">JavaSource</font> instead of <font face="monospace, monospace">JavaType</font> ?</div><div><br></div><div>Thanks</div><div>Antonio</div><div><br></div><div><font face="monospace, monospace">&nbsp;@Override</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void visit(VisitContext context, JavaResource resource)</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b><font color="#ff0000">JavaType&lt;?&gt; javaType = resource.getJavaType();</font></b></font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (javaType.isClass() &amp;&amp; !javaType.hasAnnotation(Entity.class) javaSource.hasAnnotation(MappedSuperclass.class))</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;classes.add(resource);</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch (FileNotFoundException e)</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // ignore</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</font></div><div><font face="monospace, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</font></div></div><div><br></div><div><br></div>-- <br><div>Antonio Goncalves&nbsp;<br>Software architect and Java Champion<br><br><a href="http://www.antoniogoncalves.org/" target="_blank">Web site</a>&nbsp;|&nbsp;<a href="http://twitter.com/agoncal" target="_blank">Twitter</a>&nbsp;|&nbsp;<a href="http://www.linkedin.com/in/agoncal" target="_blank">LinkedIn</a>&nbsp;|&nbsp;<a href="http://www.parisjug.org/" target="_blank">Paris JUG</a>&nbsp;|&nbsp;<a href="http://www.devoxx.fr/" target="_blank">Devoxx France</a></div>
</div></div>
</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><br><span>forge-dev mailing list</span><br><span><a href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a></span><br><span><a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a></span></div></blockquote></div><br>_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Antonio Goncalves&nbsp;<br>Software architect and Java Champion<br><br><a href="http://www.antoniogoncalves.org/" target="_blank">Web site</a>&nbsp;|&nbsp;<a href="http://twitter.com/agoncal" target="_blank">Twitter</a>&nbsp;|&nbsp;<a href="http://www.linkedin.com/in/agoncal" target="_blank">LinkedIn</a>&nbsp;|&nbsp;<a href="http://www.parisjug.org/" target="_blank">Paris JUG</a>&nbsp;|&nbsp;<a href="http://www.devoxx.fr/" target="_blank">Devoxx France</a></div>
</div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>forge-dev mailing list</span><br><span><a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a></span><br><span><a href="https://lists.jboss.org/mailman/listinfo/forge-dev">https://lists.jboss.org/mailman/listinfo/forge-dev</a></span></div></blockquote></body></html>