RFR: JDK-8214114: Switch expressions with try-catch statements
Vicente Romero
vicente.romero at oracle.com
Thu Dec 6 21:50:02 UTC 2018
Hi Jan,
Probably I'm missing something but shouldn't it be enough to generate
the right stackframe for the exception handler? Which in this case
should only contain:
stack = [ class java/lang/Exception ]
Thanks,
Vicente
On 12/6/18 11:51 AM, Jan Lahoda wrote:
> Hi,
>
> Switch expressions that contain try-catch statements don't work
> currently, as the catch handlers require that the stack is empty when
> the handler is invoked, but this may not be true when the switch
> expression is inside an expression evaluation (and so some values are
> already on the stack).
>
> The proposed solution is to stash the stack content to local variables
> before "running" the switch expression, and fill the stack content
> back when breaking out of the switch expression. This is done only if
> the try-catch statement is present in the switch expression, as it
> produces longer bytecode.
>
> Also, it turned out variables inside switch expressions in field
> initializers don't work properly (as their owner is the field, not a
> method), attempted to fix that as well.
>
> JBS: https://bugs.openjdk.java.net/browse/JDK-8214114
> Webrev: http://cr.openjdk.java.net/~jlahoda/8214114/webrev.00/
>
> How does this look?
>
> Thanks,
> Jan
More information about the compiler-dev
mailing list