<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 9/17/2013 1:57 PM, Werner Dietl wrote:
    <blockquote
cite="mid:CAJYRO=4fp2dXfn0v0ycb02_HJ=_6BmQ5pWPgbL5-UBRW-0x2ow@mail.gmail.com"
      type="cite">
      <p dir="ltr">Alex, </p>
      <p dir="ltr">I think you can't make your conclusion from the SE 7
        behavior. <br>
        SE 7 by default allows an annotation in any location. So the
        applicability check would have succeeded for an unknown
        annotation. The compiler doesn't see the FIELD target, because
        it didn't find the annotation. </p>
      <p dir="ltr">I'll look into removing the applicability error for
        SE 8.</p>
    </blockquote>
    a bug for that: <a class="moz-txt-link-freetext" href="https://bugs.openjdk.java.net/browse/JDK-8024961">https://bugs.openjdk.java.net/browse/JDK-8024961</a><br>
    <br>
    -steve<br>
    <blockquote
cite="mid:CAJYRO=4fp2dXfn0v0ycb02_HJ=_6BmQ5pWPgbL5-UBRW-0x2ow@mail.gmail.com"
      type="cite">
      <p dir="ltr">cu, WMD.</p>
      <div class="gmail_quote">On Sep 17, 2013 1:11 PM, "Alex Buckley"
        &lt;<a moz-do-not-send="true"
          href="mailto:alex.buckley@oracle.com">alex.buckley@oracle.com</a>&gt;
        wrote:<br type="attribution">
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          There should be no applicability check if the annotation's
          name can't be resolved. That's how it worked in SE 7 for the
          old targets:<br>
          <br>
          @UniqueInner<br>
          class Scopes {<br>
          &nbsp; @Target(ElementType.FIELD) // Anything but TYPE<br>
          &nbsp; @interface UniqueInner {}<br>
          }<br>
          <br>
          gives one error, about not finding the symbol UniqueInner in
          the annotation.<br>
          <br>
          I notice that an annotation on a type parameter declaration is
          treated like an annotation on a type use; the following code
          gives two errors (can't resolve + not applicable) but should
          only give one.<br>
          <br>
          class Scopes&lt;@UniqueInner T&gt; {<br>
          &nbsp; @interface UniqueInner {} &nbsp;// Not applicable to type
          parameter decls<br>
          }<br>
          <br>
          Alex<br>
          <br>
          On 9/17/2013 12:24 PM, Werner Dietl wrote:<br>
          <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
            0.8ex; border-left: 1px solid rgb(204, 204, 204);
            padding-left: 1ex;">
            Hi Steve,<br>
            <br>
            thanks for testing these cases!<br>
            In your last case:<br>
            <br>
            @UniqueInner<br>
            class Scopes&lt;T extends @UniqueInner Object&gt; {<br>
            &nbsp; &nbsp; &nbsp;@Target(ElementType.TYPE_USE)<br>
            &nbsp; &nbsp; &nbsp;@interface UniqueInner { };<br>
            }<br>
            <br>
            The compiler cannot resolve the annotation on the class
            declaration<br>
            and on Object and we therefore get the first two errors.<br>
            Because the compiler cannot resolve the annotation, it
            doesn't know<br>
            that it has meta-annotation TYPE_USE. We therefore get the
            third<br>
            error, because it sees an annotation in a type-use location
            without<br>
            knowing that it has the right meta-annotation.<br>
            <br>
            Maybe the check for the TYPE_USE target should be ignored if
            the<br>
            annotation can't be resolved?<br>
            A declaration annotation is by default valid in all
            locations, so the<br>
            issue doesn't arise for declaration annotations.<br>
            <br>
            Thoughts?<br>
            <br>
            cu, WMD.<br>
            <br>
            <br>
            On Tue, Sep 17, 2013 at 12:06 PM, Steve Sides &lt;<a
              moz-do-not-send="true"
              href="mailto:steve.sides@oracle.com" target="_blank">steve.sides@oracle.com</a>&gt;
            wrote:<br>
            <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
              0.8ex; border-left: 1px solid rgb(204, 204, 204);
              padding-left: 1ex;">
              On 9/16/2013 5:20 PM, Alex Buckley wrote:<br>
              <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
                0.8ex; border-left: 1px solid rgb(204, 204, 204);
                padding-left: 1ex;">
                <br>
                On 9/16/2013 2:42 PM, Steve Sides wrote:<br>
                <blockquote class="gmail_quote" style="margin: 0pt 0pt
                  0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204);
                  padding-left: 1ex;">
                  <br>
                  On 9/13/2013 10:42 AM, Alex Buckley wrote:<br>
                  <blockquote class="gmail_quote" style="margin: 0pt 0pt
                    0pt 0.8ex; border-left: 1px solid rgb(204, 204,
                    204); padding-left: 1ex;">
                    <br>
                    - AnnotationVersion: The @summary is imprecise - the
                    test is about the<br>
                    receiver parameter 'this', not type annotations in
                    general. In SE 6<br>
                    and 7 and 8, the annotation type 'A' with no<br>
                  </blockquote>
                  <br>
                  I'm not so sure I agree with that. Due to the 3
                  @compile lines, the test<br>
                  is about allowing type-annotations only with jdk8. The
                  fact that he put<br>
                  the annotation on 'this' appears to me to be
                  incidental. &nbsp;It may be odd<br>
                  that he chose 'this' as opposed to maybe 'String' or
                  some other more<br>
                  common usage, but it does seem to be just a usage to
                  make the general<br>
                  point and elicit the diagnostic<br>
                  "compiler.err.type.<a moz-do-not-send="true"
                    href="http://annotations.not.supported.in"
                    target="_blank">annotations.not.supported.in</a>.source:
                  1.7", and not to<br>
                  test that specific usage.<br>
                </blockquote>
                <br>
                <br>
                This test aims to show that "type annotations" didn't
                exist and now do<br>
                exist. In other words, that an annotation was not
                permitted in some<br>
                type-oriented location in 6/7 but is permitted in that
                location in 8. It is<br>
                poor form to choose a location in 8 which didn't exist
                in 6/7 - especially<br>
                when that location is frankly very obscure. I would
                suggest putting the @A<br>
                on something simple like an 'extends' clause.<br>
                <br>
                In addition, ElementType.TYPE_USE didn't exist in 6/7 so
                a reader might<br>
                ask why javac doesn't complain about that rather than
                the syntax error of<br>
                the 'this' parameter. This is why I also suggested
                having a companion test<br>
                where a ElementType from 6/7 was used.<br>
                <br>
                Alex<br>
              </blockquote>
              <br>
              Got it. While whittling on this, I have another question
              about the<br>
              compiler's behavior.<br>
              1. If I qualify the (not type) annotation,<br>
              <br>
              &nbsp; &nbsp;@Scopes.UniqueInner<br>
              &nbsp; &nbsp;class Scopes&lt;T extends @Scopes.UniqueInner
              Object&gt; {<br>
              &nbsp; &nbsp; &nbsp; @interface UniqueInner { };<br>
              &nbsp; &nbsp;}<br>
              I get 1 error, "Scopes.java:11:24:<br>
              compiler.err.annotation.type.not.applicable". This seems
              correct as I'm<br>
              using an annotation on a type usage, and the one on the
              class is okay.<br>
              <br>
              2. If I use the annotation unqualified, I get 3 errors,
              two for<br>
              "cant.resolve..." and the one above again. I can see that
              this can also be<br>
              correct.<br>
              <br>
              Scopes.java:10:2: compiler.err.cant.resolve:
              kindname.class, UniqueInner, ,<br>
              // on the class<br>
              Scopes.java:11:25: compiler.err.cant.resolve:
              kindname.class, UniqueInner, ,<br>
              // on the bound<br>
              Scopes.java:11:24: compiler.err.annotation.type.not.applicable<br>
              // not a type annotation(I assumed)?<br>
              3 errors<br>
              <br>
              3. If I use a qualified type annotation,<br>
              @Scopes.UniqueInner<br>
              class Scopes&lt;T extends @Scopes.UniqueInner Object&gt; {<br>
              &nbsp; &nbsp; &nbsp;@Target(ElementType.TYPE_USE)<br>
              &nbsp; &nbsp; &nbsp;@interface UniqueInner { };<br>
              }<br>
              it compiles without error.<br>
              <br>
              4. However, if I use an unqualified type annotation,<br>
              @UniqueInner<br>
              class Scopes&lt;T extends @UniqueInner Object&gt; {<br>
              &nbsp; &nbsp; &nbsp;@Target(ElementType.TYPE_USE)<br>
              &nbsp; &nbsp; &nbsp;@interface UniqueInner { };<br>
              }<br>
              &nbsp; I get the same 3 errors as the unqualified annotation:<br>
              <br>
              Scopes.java:10:2: compiler.err.cant.resolve:
              kindname.class, UniqueInner, ,<br>
              Scopes.java:11:25: compiler.err.cant.resolve:
              kindname.class, UniqueInner, ,<br>
              Scopes.java:11:24: compiler.err.annotation.type.not.applicable<br>
              3 errors<br>
              <br>
              Why should I get "compiler.err.annotation.type.not.applicable"
              in this last<br>
              scenario? &nbsp;For 1. I kind of assumed the third error meant
              it was not<br>
              applicable because it was not a type annotation. &nbsp;Is it
              not applicable for<br>
              reasons other than not being TYPE_USE?<br>
              <br>
              I'm thinking of using it as below (and adding a postivie
              version with<br>
              qualified name),<br>
              <br>
              @UniqueInner<br>
              class Scopes&lt;T extends @UniqueInner Object&gt; &nbsp;{<br>
              &nbsp; &nbsp; &nbsp;// Unqualified @UniqueInner is not accessible to the
              class .<br>
              &nbsp; &nbsp; &nbsp;// One has to use @Scopes.UniqueInner.<br>
              &nbsp; &nbsp; &nbsp;@Target(ElementType.TYPE_USE)<br>
              &nbsp; &nbsp; &nbsp;@interface UniqueInner { };<br>
              }<br>
              <br>
              but I'm unsure about that third error and would like to
              verify it is as<br>
              expected.<br>
              <br>
              -steve<br>
              <br>
              <br>
              <br>
              <br>
              <br>
              <br>
            </blockquote>
            <br>
            <br>
            <br>
          </blockquote>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>