Problem with the exception.

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Nov 26 06:42:30 PST 2012


Yep - this issue has been addressed while porting the lambda code into 
JDK 8 - now we are awaiting a promotion to pull bits from JDK 8 master 
to lambda, so that we'll pull this fix too. Meanwhile, you may want to 
cast the whole operand of the 'throw' statement to 
'IndexOutOfBoundsException'.

Maurizio

On 26/11/12 14:33, Alexander Zuev wrote:
> Hi,
>
>     just bumped into the problem with the new compiler - for some reason
> it does not compile the simple construction such as:
>
>       public static void init(String str) throws IndexOutOfBoundsException {
>           throw (str == null ? new IndexOutOfBoundsException("String is
> null")
>                   : new IndexOutOfBoundsException("String is not null"));
>       }
>
> This method is being compiled just fine using the jdk7 or jdk8 compilers
> but Lambda compiler issues an error
>
> Tester.java:3: error: incompatible types: Object cannot be converted to
> Throwable
>           throw (str == null ? new IndexOutOfBoundsException("String is
> null")
>           ^
> 1 error
>
>     Is this a known issue?
>
> With best regards,
> Alex
>



More information about the lambda-dev mailing list