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

Error message about referring to a private field from a super class could possibly be improved

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P4
    • tbd
    • 8, 9
    • tools

    Description

      Consider this source code:
      ---
      public class O {

          private final int i = 0;

          static class I extends O {
              void test() {
                  System.err.println(i);
              }
          }
      }
      ---

      Compiling this code on "1.8.0-b132" yields:
      O.java:7: error: non-static variable i cannot be referenced from a static context
                  System.err.println(i);
                                     ^
      1 error

      While the code is correctly rejected, the error message causes confusion. Possibilities to improve it should be evaluated.

      Attachments

        Activity

          People

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: