Hi Antonio,
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.
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.
Em 14/03/2015, às 06:41, Antonio Goncalves
<antonio.mailing(a)gmail.com> escreveu:
What do you mean by "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 ?
And in terms of performance, is there a difference ? Is it "faster" to parse
source code rather then byte code ?
Antonio
2015-03-13 23:16 GMT+01:00 George Gastaldi <ggastald(a)redhat.com>:
> 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.
>
> PS: Roaster does not support parsing of compiled java types yet, but the model is
ready for this feature when it becomes available.
>
>
>
>> Em 13/03/2015, às 18:19, Antonio Goncalves <antonio.mailing(a)gmail.com>
escreveu:
>>
>
>> Hi all,
>>
>> I am having a look at some code and realize that I don't understand the
subtle difference between JavaType and JavaSource in certain cases. In some visitor code
(see below), I see :
>>
>> JavaType<?> javaType = resource.getJavaType();
>>
>> And other times I see :
>>
>> JavaSource<?> javaSource = javaResource.getJavaType();
>>
>> So I look at the code. JavaSource extends from JavaType, adds one method, and
then they both implement similar interfaces (JavaDocCapable vs JavaDocCapableSource).
>>
>> So, in the following example, why use JavaSource instead of JavaType ?
>>
>> Thanks
>> Antonio
>>
>> @Override
>> public void visit(VisitContext context, JavaResource resource)
>> {
>> try
>> {
>> JavaType<?> javaType = resource.getJavaType();
>> if (javaType.isClass() &&
!javaType.hasAnnotation(Entity.class) javaSource.hasAnnotation(MappedSuperclass.class))
>> {
>> classes.add(resource);
>> }
>> }
>> catch (FileNotFoundException e)
>> {
>> // ignore
>> }
>> }
>>
>>
>> --
>> Antonio Goncalves
>> Software architect and Java Champion
>>
>> Web site | Twitter | LinkedIn | Paris JUG | Devoxx France
>> _______________________________________________
>> forge-dev mailing list
>> forge-dev(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/forge-dev
>
> _______________________________________________
> forge-dev mailing list
> forge-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/forge-dev
--
Antonio Goncalves
Software architect and Java Champion
Web site | Twitter | LinkedIn | Paris JUG | Devoxx France
_______________________________________________
forge-dev mailing list
forge-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/forge-dev