JDK-8187950 : javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2017-09-25
  • Updated: 2018-03-28
  • Resolved: 2018-03-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b04Fixed
Related Reports
Blocks :  
CSR :  
Relates :  
Relates :  
Sub Tasks
JDK-8199398 :  
Description
Elements.getEnclosedElements(...) throws com.sun.tools.javac.code.ClassFinder$BadClassFile, a subtype of CompletionError, which in turn is  subtype of RuntimeException, an unchecked exception. This is a surprise to the clients of these APIs, and it is not possible to realistically handle this without resorting to accessing javac internal API.

The APIs when it encounters CompletionError or BadClassFile should return back an ErrorType or it should declare an exception in the API contract, that can be caught and handled.

This is a problem for javadoc please see JDK-8187422
Comments
An updated patch showing that ignoring the CompletionFailures can cause a (significant) difference in error reporting.
26-10-2017

Attached a prototype of the fix with testcase, however with the above fix two regression tests fail: tools/javac/classreader/T7031108.java tools/javac/processing/6430209/T6430209.java These two are expecting the failure to print out an error message.
26-09-2017