RFR: JDK-8265270: Type.getEnclosingType() may fail with CompletionFailure

Vicente Romero vromero at openjdk.java.net
Tue Jun 1 17:04:19 UTC 2021


On Thu, 15 Apr 2021 11:29:44 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> The setup is a little bit tricky, but it may happen that user code calls `Type{Mirror}.getEnclosingType()` (or e.g. `Type{Mirror}.toString()` which will in turn invoke `getEnclosingType()`), and the method may throw the `CompletionFailure` (internal) exception. The reason is that the corresponding Symbol is completed using a `complete` method, instead of `apiComplete` method, which is intended to be used in API methods. `apiComplete` does the same as `complete` when running in a javac context, but will suppress the exception when the API method was invoked from a user code, avoiding the exception.
> 
> The proposed change is to use `apiComplete`, as it should be done in implementations of API methods.

looks good to me!

-------------

Marked as reviewed by vromero (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/3512


More information about the compiler-dev mailing list