package aQute.lib.exceptions;

public class Exceptions {
	static RuntimeException singleton = new RuntimeException();

	public static RuntimeException duck(Throwable t) {
		Exceptions.<RuntimeException> asUncheckedException0(t);
		return singleton;
	}

	@SuppressWarnings("unchecked")
	private static <E extends Throwable> E asUncheckedException0(Throwable throwable) throws E {
		return (E) throwable;
	}

	public static Runnable wrap(final RunnableWithException run) {
		return new Runnable() {

			@Override
			public void run() {
				try {
					run.run();
				} catch (Exception e) {
					duck(e);
				}
			}

		};
	}

	public static <T, R> org.osgi.util.function.Function<T,R> wrap(final FunctionWithException<T,R> run) {
		return new org.osgi.util.function.Function<T,R>() {

			@Override
			public R apply(T value) {
				try {
					return run.apply(value);
				} catch (Exception e) {
					duck(e);
					return null; // will never happen
				}
			}
		};
	}

}

@@ -55,55 +55,16 @@
  %7B%0A%09
-static RuntimeException singleton = new Runtime
+private 
 Exce
@@ -68,20 +68,22 @@
 xception
+s
 ()
-;%0A
+ %7B%7D
 %0A%09public
@@ -159,17 +159,21 @@
 eption%3E 
-a
+throw
 sUncheck
@@ -178,41 +178,54 @@
 cked
-Exception0(t);%0A%09%09return singleton
+(t);%0A%09%09throw new AssertionError(%22unreachable%22)
 ;%0A%09%7D
@@ -300,31 +300,28 @@
 le%3E 
-E asUncheckedException0
+void throwsUnchecked
 (Thr
@@ -351,22 +351,21 @@
 s E %7B%0A%09%09
-return
+throw
  (E) thr
@@ -554,32 +554,38 @@
 ption e) %7B%0A%09%09%09%09%09
+throw 
 duck(e);%0A%09%09%09%09%7D%0A%09
@@ -872,16 +872,22 @@
  %7B%0A%09%09%09%09%09
+throw 
 duck(e);
@@ -891,47 +891,8 @@
 e);%0A
-%09%09%09%09%09return null; // will never happen%0A
 %09%09%09%09

Fix so it actually throws the ducked exception