RFR: 8332507: compilation result depends on compilation order

Maurizio Cimadamore mcimadamore at openjdk.org
Tue May 28 13:53:01 UTC 2024


On Fri, 24 May 2024 18:59:56 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> Wildcards and separate compilation haven't been friends since like: forever. Javac has had a long standing issue of not being able to restore wildcard bounds when they are read from the classfile. Part of this is due to a restriction of not reading another class file while a given class file is being read. Without breaking this restriction we can "wait" until a class symbol is completed from a class file to have access to richer information and being able to set the right bounds to wildcards. The fix seems simple enough. Basically the proposal is to register listeners that will be invoked once a given class symbol is completely read from a class file. This tactic has been used in type inference and other areas of the compiler where another layer of indirection has been a must to fix similar problems.
> 
> It will be a great pleasure if this proposal can be the solution to this long standing issue,
> 
> TIA

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java line 605:

> 603:                 if (actuals.length() != (formals == null ? 0 : formals.length())) {
> 604:                     final List<Type> actualsCp = actuals;
> 605:                     addSymbolReadListener(t, () -> {

I wonder if we could use the completion mechanism for this - class reader should already sign itself up as a completer for the class symbols it generates?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19400#discussion_r1617285073


More information about the compiler-dev mailing list