Ah. Nested annotations. Now I get it. I guess we don&#39;t support nested annotations at the moment.<br><br>JIRA this?<br><br>Until then, you may have to parse it yourself if you *really* need it, but hopefully we can get the JavaParser updated. Curious. Why do you need this?<br>
<br>~Lincoln<br><br><div class="gmail_quote">On Tue, Jan 17, 2012 at 5:40 PM, Richard Kennard <span dir="ltr">&lt;<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Lincoln,<br>
<br>
Sorry if I&#39;m being dumb! Calling...<br>
<br>
     javaSource.getAnnotation(resolvedType)<br>
<br>
...returns null. I&#39;m not sure how it could work anyway, as we&#39;re talking about a *specific instance* of a *nested* annotation here, not just instantiating<br>
any old annotation from its class name. So presumably it needs to parse something? Here&#39;s the JavaSource:<br>
<br>
public class MockAnnotatedMethod<br>
{<br>
    @MockAnnotation( anAnnotation = @AnotherMockAnnotation(43)),<br>
    public MockAnnotatedMethod()<br>
    {<br>
    }<br>
}<br>
<br>
So I can get @MockAnnotation just fine. But then...<br>
<br>
     annotationSource.getLiteralValue(&quot;anAnnotation&quot;)<br>
<br>
...returns the String...<br>
<br>
     &quot;@AnotherMockAnnotation(43)&quot;<br>
<br>
How can I parse that back into an AnnotationImpl? Maybe I need some method other than &#39;getLiteralValue&#39;, &#39;getStringValue&#39; and &#39;getEnumValue&#39;?<br>
<br>
Regards,<br>
<br>
Richard.<br>
<div class="im"><br>
On 18/01/2012 3:37 AM, Lincoln Baxter, III wrote:<br>
&gt; I&#39;m a bit confused here. You have the JavaSource where the annotation is located, so can&#39;t you call field/method/class.getAnnotation(type), which should<br>
&gt; then give you an AnnotationImpl that you can query?<br>
&gt;<br>
&gt; What am I missing?<br>
&gt; ~Lincoln<br>
&gt;<br>
</div><div><div class="h5">&gt; On Sun, Jan 15, 2012 at 9:28 PM, Richard Kennard &lt;<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a> &lt;mailto:<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>&gt;&gt; wrote:<br>

&gt;<br>
&gt;     Lincoln,<br>
&gt;<br>
&gt;     Okay that may work for me. I tried it and Class seems okay. However Annotations are still tricky. I can do...<br>
&gt;<br>
&gt;              if (Annotation.class.isAssignableFrom(returnType))<br>
&gt;              {<br>
&gt;                 String resolvedType = StringUtils.substringAfter(literalValue, &quot;@&quot;);<br>
&gt;                 resolvedType = ((JavaSource&lt;?&gt;) this.annotationSource.getOrigin()).resolveType(resolvedType);<br>
&gt;<br>
&gt;     ...and &#39;resolvedType&#39; is a fully qualified String. But how can I turn that String into a &#39;proper&#39; AnnotationImpl Object? I need this so I can call<br>
&gt;     .getLiteralValue(...attribute...) on it.<br>
&gt;<br>
&gt;     Richard.<br>
&gt;<br>
&gt;     On 14/01/2012 4:41 AM, Lincoln Baxter, III wrote:<br>
&gt;     &gt; Hey Richard,<br>
&gt;     &gt;<br>
&gt;     &gt; There is a method in JavaSource called resolveType(); This method will return the fully qualified type of the given Class name; however, there is a big<br>
&gt;     &gt; issue here at the moment. We cannot resolve wildcards, or classes from the same package that are in the &#39;package&#39; visibility scope.<br>
&gt;     &gt;<br>
&gt;     &gt; <a href="https://issues.jboss.org/browse/FORGE-424" target="_blank">https://issues.jboss.org/browse/FORGE-424</a><br>
&gt;     &gt;<br>
&gt;     &gt; In these two cases, resolveType() will actually return the class name unchanged, which is your signal to take desperate measures, because I don&#39;t think<br>
&gt;     &gt; that we will be fixing this in time for .Final. In the case of Column.class, I would start by assuming that the class is what you expect, and in<br>
&gt;     the case<br>
&gt;     &gt; of other unknown types, at this point - unfortunately - it&#39;s going to be up to you to figure out what that type is, and if reasonable assumptions<br>
&gt;     can be<br>
&gt;     &gt; made.<br>
&gt;     &gt;<br>
&gt;     &gt; Sorry about this, I know it&#39;s a big gap, but it&#39;s going to take a lot of work to fix this as you might be able to see in the issue. But definitely call<br>
&gt;     &gt; resolveType() as a first step, then you&#39;ll have to &quot;worry&quot; about handling potential issues where the type information is not available.<br>
&gt;     &gt;<br>
&gt;     &gt; We also can&#39;t tell if a Class literal is a class, interface, enum, etc...<br>
&gt;     &gt;<br>
&gt;     &gt; ~Lincoln<br>
&gt;     &gt;<br>
&gt;     &gt; On Thu, Jan 12, 2012 at 11:46 PM, Richard Kennard &lt;<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a> &lt;mailto:<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>&gt;<br>

</div></div><div class="im">&gt;     &lt;mailto:<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a> &lt;mailto:<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>&gt;&gt;&gt; wrote:<br>

&gt;     &gt;<br>
&gt;     &gt;     Lincoln,<br>
&gt;     &gt;<br>
&gt;     &gt;     As you may recall, the new &#39;static Metawidget&#39; scaffolding tries to reuse Inspectors between the runtime/static worlds. To do this, it needs to<br>
&gt;     reify the<br>
&gt;     &gt;     annotations from org.jboss.forge.parser.java.Annotations into &#39;proper&#39; java.lang.annotation.Annotations.<br>
&gt;     &gt;<br>
&gt;     &gt;     This is mostly working, but I am struggling with reifying two things:<br>
&gt;     &gt;<br>
&gt;     &gt;     1. If the annotation&#39;s value is a Class<br>
&gt;     &gt;     2. If the annotation&#39;s value is another annotation<br>
&gt;     &gt;<br>
&gt;     &gt;     The problem is the same in both cases - I am lacking the qualified name of the class/annotation. If they user enters:<br>
&gt;     &gt;<br>
&gt;     &gt;         @MyAnnotation( Column.class )<br>
&gt;     &gt;<br>
&gt;     &gt;     Then I need to know that it&#39;s actually a javax.persistence.Column.class. This is a bit beyond me! I have left a couple of TODOs in<br>
&gt;     ForgePropertyStyle and<br>
&gt;     &gt;     in ForgePropertyStyleTest. Could you take a look?<br>
&gt;     &gt;<br>
&gt;     &gt;     Regards,<br>
&gt;     &gt;<br>
&gt;     &gt;     Richard.<br>
&gt;     &gt;     _______________________________________________<br>
&gt;     &gt;     forge-dev mailing list<br>
</div>&gt;     &gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>&gt; &lt;mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>&gt;&gt;<br>

<div class="im">&gt;     &gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt; --<br>
&gt;     &gt; Lincoln Baxter, III<br>
&gt;     &gt; <a href="http://ocpsoft.com" target="_blank">http://ocpsoft.com</a><br>
&gt;     &gt; <a href="http://scrumshark.com" target="_blank">http://scrumshark.com</a><br>
&gt;     &gt; &quot;Keep it Simple&quot;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt; _______________________________________________<br>
&gt;     &gt; forge-dev mailing list<br>
</div>&gt;     &gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>&gt;<br>
<div class="HOEnZb"><div class="h5">&gt;     &gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     forge-dev mailing list<br>
&gt;     <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>&gt;<br>
&gt;     <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Lincoln Baxter, III<br>
&gt; <a href="http://ocpsoft.com" target="_blank">http://ocpsoft.com</a><br>
&gt; <a href="http://scrumshark.com" target="_blank">http://scrumshark.com</a><br>
&gt; &quot;Keep it Simple&quot;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; forge-dev mailing list<br>
&gt; <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
<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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.com">http://ocpsoft.com</a><br><a href="http://scrumshark.com">http://scrumshark.com</a><br>&quot;Keep it Simple&quot;<br>