}
static Callable<EncapsulatedValueCodec> loader(final Class<?> typeClz) {
- return new Callable<EncapsulatedValueCodec>() {
- @Override
- public EncapsulatedValueCodec call() throws IllegalAccessException, NoSuchMethodException, SecurityException {
- final Method m = typeClz.getMethod("getValue");
- final MethodHandle getter = LOOKUP.unreflect(m).asType(OBJ_METHOD);
- final Class<?> valueType = m.getReturnType();
+ return () -> {
+ final Method m = typeClz.getMethod("getValue");
+ final MethodHandle getter = LOOKUP.unreflect(m).asType(OBJ_METHOD);
+ final Class<?> valueType = m.getReturnType();
- final MethodHandle constructor = LOOKUP.findConstructor(typeClz,
- MethodType.methodType(void.class, valueType)).asType(OBJ_METHOD);
- return new EncapsulatedValueCodec(typeClz, constructor, getter, valueType);
- }
+ final MethodHandle constructor = LOOKUP.findConstructor(typeClz,
+ MethodType.methodType(void.class, valueType)).asType(OBJ_METHOD);
+ return new EncapsulatedValueCodec(typeClz, constructor, getter, valueType);
};
}
try {
return constructor.invokeExact(input);
} catch (Throwable e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
try {
return getter.invokeExact(input);
} catch (Throwable e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
}
\ No newline at end of file