Elements#getTypeElement and completion failures (JDK-8177436)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Elements#getTypeElement and completion failures (JDK-8177436)

Liam Miller-Cushon
I have a question about Elements#getTypeElement and CompletionFailures related to JDK-8177436. The summary of the bug is that getTypeElement catches completion failures and returns null for symbols that cannot be found, and javac relies on completion failures to detect missing symbols. So if a plugin or annotation processor calls getTypeElement before javac completes the symbol, javac fails to report an error and gets into a bad state.

One possible fix would be to avoid relying on completion failures, and always check for errors before using symbols. This seems difficult to do exhaustively, and it requires plugins and annotation processors to also get it right.

Another option would be to avoid caching the result of Symbol#complete for missing symbols, and rethrow the original completion failure. Is that worth considering? I attached a patch that illustrates the idea. It avoids the crash in JDK-8177436.

8177436.patch (4K) Download Attachment