JEP 280 (Indify String Concat) integration

Alex Buckley alex.buckley at oracle.com
Fri Jan 22 21:20:42 UTC 2016


On 1/22/2016 9:37 AM, Aleksey Shipilev wrote:
> On 01/22/2016 05:44 PM, Peter Levart wrote:
>> If StringConcatException ever gets thrown, will it propagate out of the
>> concatenation expression execution? If yes, then it should probably be
>> an unchecked exception, right?
>
> StringConcatException is modeled after LambdaConversionException: it
> covers the linkage invariants, and it is thrown from bootstrap method
> only. When BSM throws, call site initialization fails with
> BootstrapMethodError, having this exception as the cause. Therefore, I
> see no particular reason in making that exception unchecked.

In other words, StringConcatException will never (from the POV of the 
Java program) be the reason why evaluation of a string concat expression 
fails. The Java program would never catch StringConcatException if it 
was an unchecked exception class (since the JVM wraps SCE in BSME) ... 
and the Java program could never write 'catch (StringConcatException e)' 
if it was a checked exception class. So, there is no need to mention it 
in JLS 15.6.

Instead, the reason why evaluation fails may be a BootstrapMethodError. 
This is already anticipated by "Various linkage and virtual machine 
errors may also occur during the evaluation of an expression." The Java 
program is free to write 'catch BootstrapMethodError' if it wishes, and 
occasionally the catch block will execute.

Alex


More information about the compiler-dev mailing list