final LinkerServices ls = new LinkerServicesImpl(new TypeConverterFactory(Collections.singleton(
new GuardingTypeConverterFactory() {
@Override
public GuardedInvocation convertToType(Class<?> sourceType, Class<?> targetType) {
if(targetType == int.class) {
return new GuardedInvocation(new Lookup(MethodHandles.publicLookup()).findVirtual(
Double.class, "intValue", MethodType.methodType(int.class)).asType(
MethodType.methodType(int.class, sourceType)), Guards.isOfClass(
Double.class, MethodType.methodType(boolean.class, sourceType)));
}
return null;