Problem with the exception.

Alexander Zuev alexander.zuev at oracle.com
Mon Nov 26 06:33:04 PST 2012


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