ClassLoader thisLoader = ClassLoaderParameterUnwrappedTest.class.getClassLoader();
ClassLoader dep1Loader = registry.getAddon(AddonId.from("dep1", "1")).getClassLoader();
Class<?> foreignType = dep1Loader.loadClass(IterableFactory.class.getName());
Object delegate = foreignType.newInstance();
IterableFactory enhancedFactory = (IterableFactory) ClassLoaderAdapterBuilder.callingLoader(thisLoader)
.delegateLoader(dep1Loader).enhance(delegate);
Assert.assertTrue(Proxies.isForgeProxy(enhancedFactory));
Object foreignInstance = dep1Loader
.loadClass(ClassWithClassAsParameter.class.getName())
.getConstructor(Class.class)
.newInstance(foreignType);
ClassLoaderAdapterBuilderDelegateLoader builder = ClassLoaderAdapterBuilder
.callingLoader(thisLoader)
.delegateLoader(dep1Loader);
Object enhancedFilter = builder.enhance(foreignInstance);
ClassWithClassAsParameter classFilter = (ClassWithClassAsParameter) enhancedFilter;
Assert.assertTrue(Proxies.isForgeProxy(classFilter));
Assert.assertTrue(classFilter.verify(foreignType));
Assert.assertTrue(classFilter.verify(delegate.getClass()));
Assert.assertTrue(classFilter.verify(enhancedFactory.getClass()));
}