Elements#getTypeElement and completion failures (JDK-8177436)
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.