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

[lworld] JLS 6.5 "Determining the Meaning of a Name" needs updates for handling .ref and .val tokens

    Details

    • Type: Bug
    • Status: New
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: repo-valhalla
    • Fix Version/s: repo-valhalla
    • Component/s: specification
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dlsmith Dan Smith
                Reporter:
                sadayapalam Srikanth Adayapalam
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: