JDK-8252205 : [lworld] JLS 6.5 "Determining the Meaning of a Name" needs updates for handling .ref and .val tokens
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: repo-valhalla
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2020-08-24
  • Updated: 2022-06-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
repo-valhallaUnresolved
Related Reports
Blocks :  
Description
ATM, the treatment of .ref and .val tokens by javac is rather crude and hacky - just good enough to prototype/enable experiments with the use cases we are concerned with

The following code extract shows what we do when we encounter
.val or .ref in source code.

{code}
       /** Determine symbol referenced by a Select expression,
         *
         *  @param tree   The select tree.
         *  @param site   The type of the selected expression,
         *  @param env    The current environment.
         *  @param resultInfo The current result.
         */
        private Symbol selectSym(JCFieldAccess tree,
                                 Symbol location,
                                 Type site,
                                 Env<AttrContext> env,
                                 ResultInfo resultInfo) {
            DiagnosticPosition pos = tree.pos();
            Name name = tree.name;
            switch (site.getTag()) {
                // ... various ...
            case CLASS:
                // ... various 
                if (name == names.ref && site.isValue() && resultInfo.pkind.contains(KindSelector.TYP)) {
                    return site.tsym.referenceProjection();
                } else if (name == names.val && site.isValue() && resultInfo.pkind.contains(KindSelector.TYP)) {
                    return site.tsym;
                } 
            // ... various 
{code}

https://bugs.openjdk.java.net/browse/JDK-8244229 is raised with the objective of making the handling of these tokens robust in the context of classification/meaning/scope of names in the manner of JLS chapter 6. 

This ticket is raised for the specification changes needed.