On Mon, 1 Sep 2025 22:01:49 GMT, Vicente Romero <[email protected]> wrote:
>> Before this fix only strict fields were readable in the prologue phase. The >> proposed fix should allow any instance fields of identity classes to be >> readable in the prologue phase. This implies changes in flow analysis as >> before we were only tracking final and strict fields. There is also some >> "cooperation" needed in the code to detect cases when reading a field is not >> allowed in the prologue phase. For example some methods in Resolve don't >> have all the needed information at the moment they are dealing with some >> ASTs and part of the processing needs to be done in Attr >> >> TIA >> >> This PR is a remake of https://github.com/openjdk/valhalla/pull/1490 > > Vicente Romero has updated the pull request incrementally with one additional > commit since the last revision: > > minor refactoring src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1387: > 1385: void analyzeSymbol(JCTree tree) { > 1386: Symbol sym = TreeInfo.symbolFor(tree); > 1387: if (isInLHS && !insideLambdaOrClassDef) { Question: for stuff that is NOT in LHS -- shouldn't we check that preview features are enabled? E.g. we don't want to allow reads in prologue unless `--enable-preview` is present, right? src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1465: > 1463: sym.isMemberOf(env.enclClass.sym, types)) { > 1464: // Allow "Foo.this.x" when "Foo" is (also) an outer > class, as this refers to the outer instance > 1465: if (base != null) { (optional) style only -- instead of setting `base` and then checking `base != null`, we could just rewrite the `if` as `if (tree.hasTag(SELECT))` ? ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/1523#discussion_r2318981814 PR Review Comment: https://git.openjdk.org/valhalla/pull/1523#discussion_r2318977499
