Use rethrow puzzler in the ClassValue
This commit is contained in:
parent
6487940a79
commit
04ab42cdf5
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue