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

spurious error message for compact constructors with throws clause

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 15
    • None
    • tools
    • b11

      javac generates spurious error messages for this test case:

      record R(){
              public R throws Exception {}
      }

      R.java:2: error: <identifier> expected
              public R throws Exception {}
                      ^
      R.java:2: error: field declaration must be static
              public R throws Exception {}
                       ^
        (consider replacing field with record component)
      R.java:2: error: invalid method declaration; return type required
              public R throws Exception {}
                              ^
      Note: R.java uses preview language features.
      Note: Recompile with -Xlint:preview for details.
      3 errors

      a better error message should be generated

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: