RFR: JDK-8252031: --patch-module java.base= may fail with "cyclic inheritance involving Object"

Jan Lahoda jan.lahoda at oracle.com
Wed Aug 19 12:42:10 UTC 2020


When running javac with --patch-module java.base=<dir>, where <dir> 
contains a copy of java/lang, the compilation may (depending on exact 
circumstances) incorrectly fail with:
error: cyclic inheritance involving Object

The reason is that Types.asSuper is setting Flags.LOCKED on Symbols to 
detect cycles. But it also completes some of the Symbols, and if it 
tries to complete a Symbol that originates in source, cycle detection in 
for that Symbol is triggered using Check.checkNonCyclic. And that cycle 
detection is also using the LOCKED flag to detect cycles. So there may 
be interference between these two uses, leading to the false error.

The proposal is to avoid using the flag in asSuper, and use a simple Set 
to detect the cycles.

Possible alternative solutions include using a different flag (which is 
troublesome due to the limited supply of flags), or carefully avoid the 
unwanted interference by not completing while the flag is set (which is 
somewhat fragile).

Proposed webrev:

JBS: https://bugs.openjdk.java.net/browse/JDK-8252031

What do you think?


More information about the compiler-dev mailing list