public static void ensureSerializable(Object obj) {
        try {
            InstantiationUtil.serializeObject(obj);
        } catch (Exception e) {
            throw new InvalidProgramException("Object " + obj + " is not serializable", e);
        }
    }
@Test
    void testNonSerializable() {
        assertThatThrownBy(
                        () -> {
                            MapCreator creator = new NonSerializableMapCreator();
                            MapFunction<Integer, Integer> map = creator.getMap();

                            ClosureCleaner.ensureSerializable(map);

                            int result = map.map(3);
                            assertThat(result).isEqualTo(4);
                        })
                .isInstanceOf(InvalidProgramException.class);
    }