How does Lombok.val actually work? : <p><a href="https://projectlombok.org/features/val.html" rel="noreferrer">Lombok.val</a> allows you to </p>

<blockquote>
  <p>use val as the type of a local variable declaration instead of
  actually writing the type. When you do this, the type will be inferred from the initializer expression. The local variable will also be made final.</p>
</blockquote>

<p>So instead of </p>

<pre><code>final ArrayList&lt;String&gt; example = new ArrayList&lt;String&gt;();
</code></pre>

<p>You can write</p>

<pre><code>val example = new ArrayList&lt;String&gt;();
</code></pre>

<hr>

<p>I've tried to do some research into how this actually works but there doesn't seem to be a huge amount of information. Looking at <a href="https://github.com/rzwitserloot/lombok/blob/master/src/core/lombok/val.java" rel="noreferrer">the github page</a>, I can see that <code>val</code> is an annotation type. The annotation <em>type</em> is then used, rather than an actual annotation.</p>

<p>I wasn't even aware you could even use annotation types in this manner but upon testing it the following code is indeed valid. However, I'm still not sure why you would ever want to use the type in this way.</p>

<pre><code>public class Main
{
    public @interface Foo { }

    public static void main(String... args)
    {       
        Foo bar;
        System.out.println("End");
    }
}
</code></pre>

<p>How does Lombok process these usages if they are not annotations, but annotation <em>types</em>? To my (obviously incorrect) understanding, the syntax should look more like:</p>

<pre><code>@Val foo = new ArrayList&lt;String&gt;();
</code></pre>

<p>(I'm aware constraints of annotations mean the above is not valid syntax)</p>
