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

Parser confused by combination of parens and explicit type args

    Details

    • Subcomponent:
    • Resolved In Build:
      b27
    • CPU:
      generic, x86
    • OS:
      generic, linux, windows_7
    • Verification:
      Not verified

      Description

      Consider the following program, Util.java:

      public class Util {
          @SuppressWarnings("unchecked")
          public static <T> T cast(Object x) {
      return (T) x;
          }

          static {
      Util.<Object>cast(null);
      (Util.<Object>cast(null)).getClass();
          }
      }

      The first statement in the static initializer compiles without problems. But the second statement produces the following error:

      Util.java:9: illegal start of expression
              (Util.<Object>cast(null)).getClass();
                    ^

      Various experiments show that it is the combination of the parentheses and the explicit type argument that provokes the problem.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                emcmanus Eamonn McManus
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: