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

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8, 9
    • Fix Version/s: tbd_major
    • Component/s: 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

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

              Dates

              • Created:
                Updated: