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

Guoxiong Li github.com+13688759+lgxbslgx at openjdk.java.net
Thu Dec 10 15:24:55 UTC 2020

> 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.

Guoxiong Li has updated the pull request incrementally with one additional commit since the last revision:

  Fix multi-catch test case.


  - all: https://git.openjdk.java.net/jdk/pull/1648/files
  - new: https://git.openjdk.java.net/jdk/pull/1648/files/d10b1d86..6c652343

 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=1648&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=1648&range=00-01

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1648.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1648/head:pull/1648

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

More information about the compiler-dev mailing list