public static <T> Iterator<Class<T>> classIterator(Class<T> expectedType, String factoryId, ClassLoader classLoader) {
        Set<ServiceDefinition> serviceDefinitions = getServiceDefinitions(factoryId, classLoader);
        return new ClassIterator<>(serviceDefinitions, expectedType);
    }
@Test
    public void testMultipleClassloaderLoadsTheSameClass() throws Exception {
        ClassLoader parent = this.getClass().getClassLoader();

        //child classloader will steal bytecode from the parent and will define classes on its own
        ClassLoader childLoader = new StealingClassloader(parent);

        Class<?> interfaceClass = childLoader.loadClass(DataSerializerHook.class.getName());
        Iterator<? extends Class<?>> iterator
                = ServiceLoader.classIterator(interfaceClass, "com.hazelcast.DataSerializerHook", childLoader);

        //make sure some hook were found.
        assertTrue(iterator.hasNext());

        while (iterator.hasNext()) {
            Class<?> hook = iterator.next();
            assertEquals(childLoader, hook.getClassLoader());
        }
    }