RFR: 8257740: Compiler crash when compiling type annotation on multicatch inside lambda

Joel Borggrén-Franck jfranck at openjdk.java.net
Thu Dec 10 14:02:38 UTC 2020


On Sun, 6 Dec 2020 08:17:29 GMT, Guoxiong Li <github.com+13688759+lgxbslgx at openjdk.org> wrote:

> Hi all,
> 
> When translating a lambda expression to method, the method `LambdaToMethod.LambdaAnalyzerPreprocessor.LambdaTranslationContext.translate(final Symbol sym, LambdaSymbolKind skind)` creates new VarSymbol(s) according to the old VarSymbol(s). But this `translate` method doesn't set the field `data`  of the new VarSymbol. Maybe it is because the field `data` is unused in later phase.
> 
> Unfortunately, `com.sun.tools.javac.jvm.Code.fillExceptionParameterPositions` and `com.sun.tools.javac.jvm.Code.fillLocalVarPosition` would use the field `data` if the `data` is `ElementKind.EXCEPTION_PARAMETER`.
> 
> It causes the exception_index won't be set in `fillExceptionParameterPositions`. Later, if the exception_index is used, the compiler will crash with error `java.lang.AssertionError: exception_index is not set`.
> 
> This patch fixes it and adds corresponding test cases.
> In my patch, I only set the field ` data`  if  the `data` is `ElementKind.EXCEPTION_PARAMETER`. Because I don't see another situation that the field `data` would be used.
> 
> Thank your for taking the time to review.
> 
> Best Regards.

test/langtools/tools/javac/T8257740/T8257740_2.java line 42:

> 40:             try {
> 41:                 System.out.println();
> 42:             } catch (@T8257740_2_Anno Exception e) { // multi-catch

This looks like a uni-catch?

test/langtools/tools/javac/T8257740/T8257740_1.java line 27:

> 25:  * @test
> 26:  * @bug 8257740
> 27:  * @summary Compiler crash when compiling type annotation on uni-catch inside lambda

Did you manage to make it crash on a uni-catch as well?

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

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


More information about the compiler-dev mailing list