Elements#getTypeElement and completion failures (JDK-8177436)

Liam Miller-Cushon cushon at google.com
Thu Mar 23 19:08:38 UTC 2017

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

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20170323/5e598d45/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 8177436.patch
Type: text/x-patch
Size: 3374 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20170323/5e598d45/8177436.patch>

More information about the compiler-dev mailing list