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

Definitely unassigned field can be accessed

XMLWordPrintable

    • b13
    • Verified

        The following erroneous code compiles on JDK8:

        public class Test {
          final int y;
          final int z = this.y;
          { y = 1; }
        }

        If z is instead initialized to 'y', then the appropriate error is given ("variable y might not have been initialized").

        This may be related to a javac change for 7004835, whereby 'this.y' (not just 'y') is an "access" to a variable. Of course, since 'this.y' is an access, and the y variable is definitely unassigned at that point, an error is due.

              pgovereau Paul Govereau (Inactive)
              abuckley Alex Buckley
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: