8263614: javac allows local variables to be accessed from a static context #4004
This is a tricky area, so I played a little with the (unchanged) code, to get an idea of what was wrong. It seems to me that the behavior of
This doesn't seem too bad - but there is an issue, e.g. in the example mentioned in the JBS issue: we look into locals (step 1) regardless of the value of
To rectify this issue, I came up with the following, relatively minimal fix:
The idea here is that, whatever symbol is found during step (1), if
It is likely that, as in your patch, similar changes would be needed for other routines such as
I'm doing more investigation. The code for resolving types is definitively complex. It seems to me that the complexity comes from 3 problems:
Here the env for
Here the env for
This should obviously work, although, in compiler terms, there's not much difference between (3) and (2).
I'm currently looking into all the changes made in this area in recent times, and see if there's an easier path to support all this.
This is what I came up with:
It reverts some of the code changes made for records, and reverts the code to a simpler state (the isInnerClassOfMethod) is no longer needed. This passes all tests, including the modified RecordCompilationTests.
@vicente-romero-oracle This change now passes all automated pre-integration checks.
After integration, the commit message for the final commit will be:
At the time when this comment was updated there had been 137 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
@vicente-romero-oracle Since your change was applied there have been 137 commits pushed to the
Your commit was automatically rebased without conflicts.
Pushed as commit b8856b1.