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}: */
|
/** Hack to rethrow unknown Exceptions from {@link MethodHandle#invokeExact}: */
|
||||||
@SuppressWarnings("unchecked")
|
@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;
|
throw (T) t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,11 +158,12 @@ public final class DefBootstrap {
|
||||||
final ClassValue<MethodHandle> megamorphicCache = new ClassValue<MethodHandle>() {
|
final ClassValue<MethodHandle> megamorphicCache = new ClassValue<MethodHandle>() {
|
||||||
@Override
|
@Override
|
||||||
protected MethodHandle computeValue(Class<?> receiverType) {
|
protected MethodHandle computeValue(Class<?> receiverType) {
|
||||||
|
// it's too stupid that we cannot throw checked exceptions... (use rethrow puzzler):
|
||||||
try {
|
try {
|
||||||
return lookup(flavor, name, receiverType, callArgs).asType(type);
|
return lookup(flavor, name, receiverType, callArgs).asType(type);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable t) {
|
||||||
// XXX: fix that
|
Def.rethrow(t);
|
||||||
throw new RuntimeException(e);
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue