Intersection bounds on 'throws' type variables

Mark Mahieu mark at twistedbanana.demon.co.uk
Sun Jun 22 19:15:30 PDT 2008


Should 'throws' type variables accept intersection type bounds?  The  
parser doesn't seem to like that at the moment:


class MultipleBoundsOnThrowsTypeVar {

	interface Marker {}
	static class MyException extends Exception implements Marker {}

	static <throws X extends Throwable & Marker> void foo({==>void  
throws X} block) throws X { block.invoke(); }
	
	public static void main(String[] args) throws MyException {
		
		foo({=> if (args.length == 1) throw new MyException(); });
	}
}


MultipleBoundsOnThrowsTypeVar.java:6: > expected
         static <throws X extends Throwable & Marker> void foo 
({==>void throws X} block) throws X { block.invoke(); }
                                           ^
MultipleBoundsOnThrowsTypeVar.java:6: illegal start of type
         static <throws X extends Throwable & Marker> void foo 
({==>void throws X} block) throws X { block.invoke(); }
                                            ^
MultipleBoundsOnThrowsTypeVar.java:6: '(' expected
         static <throws X extends Throwable & Marker> void foo 
({==>void throws X} block) throws X { block.invoke(); }
                                                    ^
3 errors


Regards,

Mark



More information about the closures-dev mailing list