Use rethrow puzzler in the ClassValue

This commit is contained in:
Uwe Schindler 2016-06-15 18:36:45 +02:00
parent 6487940a79
commit 04ab42cdf5
2 changed files with 5 additions and 4 deletions

View File

@ -138,7 +138,7 @@ public final class Def {
/** Hack to rethrow unknown Exceptions from {@link MethodHandle#invokeExact}: */
@SuppressWarnings("unchecked")
private static <T extends Throwable> void rethrow(Throwable t) throws T {
static <T extends Throwable> void rethrow(Throwable t) throws T {
throw (T) t;
}

View File

@ -158,11 +158,12 @@ public final class DefBootstrap {
final ClassValue<MethodHandle> megamorphicCache = new ClassValue<MethodHandle>() {
@Override
protected MethodHandle computeValue(Class<?> receiverType) {
// it's too stupid that we cannot throw checked exceptions... (use rethrow puzzler):
try {
return lookup(flavor, name, receiverType, callArgs).asType(type);
} catch (Throwable e) {
// XXX: fix that
throw new RuntimeException(e);
} catch (Throwable t) {
Def.rethrow(t);
throw new AssertionError();
}
}
};