Skip to content

Conversation

@biboudis
Copy link
Member

@biboudis biboudis commented May 26, 2025

There are various occasions that the qualifier of an inner type needs to be normalized.

Briefly:

  • This occurs when there is an explicit type application in the signature of the method or a type application operation or when type checking an expression operation (e.g., G.Getter in the first example, M.B<?> in the second example).
  • The reference to an inner type may not be explicitly qualified (e.g., B<?> which is not qualified but its type needs be calculated as seen from A<String>.B<?>).

Semi-formally:

  • A type reference is simple name R:

    • R is a non-inner class type, nothing to do
    • R is an inner class type, we need to find an implicit type qualifier S<T>.R, where S is the class in which R is enclosed
    • R is an array type A[], repeat the analysis for the simple type name A, and then use the implicit type qualifier to rewrite the array
  • A type reference is a qualified name Q.R

    • find the supertype of Q, namely S<T>, where S is the class in which R is enclosed
// example 1
static class Usage1<T, G extends Getters<T>> {
  public T test(G.Getter getter) {
      return getter.get();
  }
}

// example 2
class A<T> {
  protected class B<V> {}

  public static <T, M extends A<T>> void f(Object g) {
    @SuppressWarnings("unchecked")
    M.B<?> mapping = (M.B<?>) g;
  }
}

// example 3
class A<T> {
    class B<W> {
        public T rett() { return null; }
    }
}

class C extends A<String> {
    static class D {
        {
            B<?> b = null;
            String s = b.rett();
        }
    }
}

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change requires CSR request JDK-8359213 to be approved
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issues

  • JDK-8357653: Inner classes of type parameters emitted as raw types in signatures (Bug - P4)
  • JDK-8357472: NPE in Types.containsType for type variable used as a qualifier (Bug - P3)
  • JDK-8359213: Inner classes of type parameters emitted as raw types in signatures (CSR)

Reviewers

Contributors

  • Maurizio Cimadamore <mcimadamore@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25451/head:pull/25451
$ git checkout pull/25451

Update a local copy of the PR:
$ git checkout pull/25451
$ git pull https://git.openjdk.org/jdk.git pull/25451/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25451

View PR using the GUI difftool:
$ git pr show -t 25451

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25451.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 26, 2025

👋 Welcome back abimpoudis! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented May 26, 2025

@biboudis This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8357653: Inner classes of type parameters emitted as raw types in signatures
8357472: NPE in Types.containsType for type variable used as a qualifier

Co-authored-by: Maurizio Cimadamore <mcimadamore@openjdk.org>
Reviewed-by: mcimadamore, vromero, liach

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 79 new commits pushed to the master branch:

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented May 26, 2025

@biboudis The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label May 26, 2025
@biboudis
Copy link
Member Author

/csr needed

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label May 26, 2025
@openjdk
Copy link

openjdk bot commented May 26, 2025

@biboudis has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@biboudis please create a CSR request for issue JDK-8357653 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@biboudis
Copy link
Member Author

/contributor add @mcimadamore

@openjdk
Copy link

openjdk bot commented May 26, 2025

@biboudis
Contributor Maurizio Cimadamore <mcimadamore@openjdk.org> successfully added.

@biboudis biboudis marked this pull request as ready for review May 26, 2025 16:06
@openjdk openjdk bot added the rfr Pull request is ready for review label May 26, 2025
@mlbridge
Copy link

mlbridge bot commented May 26, 2025

@mcimadamore
Copy link
Contributor

Looks good - I'm unsure whether we should unify the two routines as part of this fix, or if we wanna keep that for a separate PR (given that might be a potential extra risk)

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks sensible to me

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@biboudis
Copy link
Member Author

biboudis commented Jul 7, 2025

/issue add JDK-8357472

@openjdk
Copy link

openjdk bot commented Jul 7, 2025

@biboudis
Adding additional issue to issue list: 8357472: NPE in Types.containsType for type variable used as a qualifier.

Copy link
Contributor

@mcimadamore mcimadamore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new fix looks good. IMHO the main thing we need to add here is some better comments for asEnclosingSuper and asOuterSuper to describe in which cases they should be used.

@biboudis
Copy link
Member Author

biboudis commented Jul 7, 2025

I revised the text a bit. Let me know if that's a good direction.

I am still think about the opportunity we may have here o unify the two methods; maybe also by introducing some enum to emphasize the different modes of interpretation for qualified types?

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@mcimadamore mcimadamore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to go. If you want to add more examples or comments in the javadoc, that might be useful, but the PR as is looks good.

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks!

Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bikeshedding

Co-authored-by: Chen Liang <liach@openjdk.org>
Copy link
Contributor

@mcimadamore mcimadamore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good, I left two optional minor doc changes

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Jul 15, 2025
Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore@users.noreply.github.com>
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jul 15, 2025
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 15, 2025
@biboudis
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 16, 2025

Going to push as commit 5e4a2ea.
Since your change was applied there have been 113 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 16, 2025
@openjdk openjdk bot closed this Jul 16, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 16, 2025
@openjdk
Copy link

openjdk bot commented Jul 16, 2025

@biboudis Pushed as commit 5e4a2ea.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants