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

Poorly worded error message when attempting to assign to this

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 9
    • 7u40
    • tools
    • b112
    • windows_7
    • Not verified

      FULL PRODUCT VERSION :
      java version "1.7.0_11"
      Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
      Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Attempting to assign a value to "this" produces an error message that refers "to final variable this". However, "this" is a Java keyword (??15.8.3) and not a variable at all. In particular, it does not fit the description of any of the seven kinds of variables specified in ??4.12.3 of the spec.

      The error message should be changed to refer to "keyword this" instead of "final variable this".

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile any code that attempts to assign a value to "this".

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expect to see an error message something like:

      Test.java:4: error: cannot assign a value to keyword this
      this = null;
      ^


      ACTUAL -
      Received a poorly worded error message.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Test.java:4: error: cannot assign a value to final variable this
      this = null;
      ^


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Test
      {
      void test() {
      this = null;
      }
      }
      ---------- END SOURCE ----------

            alundblad Andreas Lundblad (Inactive)
            aefimov Aleksej Efimov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: