RFR: JDK-8220041: NullPointerException at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0
Vicente Romero
vicente.romero at oracle.com
Tue Jul 9 16:06:01 UTC 2019
looks good,
Vicente
On 7/9/19 10:54 AM, Jan Lahoda wrote:
> Hi,
>
> Consider code like:
> ---
> I<String> lambdaCapture1(int i) {
> I<String> r = switch (i) {
> default -> {
> String k = "D";
> yield () -> k; //need to capture k here
> }
> };
>
> return r;
> }
>
> interface I<T> {
> public T t();
> }
> ---
>
> "k" needs to be captured, but LambdaToMethod fails to recognize that,
> as the enclosing Frame is for a variable declaration, which does not
> check the definitions under the variable decl (since before switch
> expressions, this could not happen). This then eventually leads either
> to a compiler crash, or a failure at runtime. The proposed solution is
> to check local variables in the variables frame, to see if they should
> be captured or not.
>
> JBS: https://bugs.openjdk.java.net/browse/JDK-8220041
> Webrev: http://cr.openjdk.java.net/~jlahoda/8220041/webrev.00/
>
> How does this look?
>
> Thanks,
> Jan
More information about the compiler-dev
mailing list