Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8232857

[local-methods] Generic local methods are not annotatable

    Details

    • Type: Bug
    • Status: New
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: repo-amber
    • Fix Version/s: repo-amber
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      Compiling the following program:

      public class X {
          @interface A {
          }

          @A
          <T extends X> T id(T t) {
              return null;
          }
      public static void main(String [] args) {
              
              @A
              <T extends X> T id(T t) {
                  return t;
              }

              X x = new X();
              X i = id(x);
              System.out.println("i = " + i + " x = " + x);
      }
      }

      results in:

      X.java:12: error: illegal start of type
              <T extends X> T id(T t) {
              ^
      X.java:12: error: > expected
              <T extends X> T id(T t) {
                 ^
      X.java:12: error: not a statement
              <T extends X> T id(T t) {
                          ^
      X.java:12: error: ';' expected
              <T extends X> T id(T t) {
                             ^
      X.java:12: error: ')' expected
              <T extends X> T id(T t) {
                                  ^
      X.java:12: error: not a statement
              <T extends X> T id(T t) {
                                   ^
      X.java:12: error: ';' expected
              <T extends X> T id(T t) {
                                    ^
      7 errors

      See that the instance method is annotatable while the local method is not.

        Attachments

          Activity

            People

            • Assignee:
              sadayapalam Srikanth Adayapalam
              Reporter:
              sadayapalam Srikanth Adayapalam
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: