square/dagger — pull request #271 by cgruber (2013-06-05 07:17:16+00:00)
Title: Request classloading from the classloader of the requesting object

Request classloading from the classloader of the requesting object, not the current thread's context classloader.

Use the context classloader only for classes loaded in the bootstrap loader (say, if Array.class or String.class is an entry point). Also use the context classloader in the compile-time analysis-only adapters/bindings, since they all happen in the process of the java compiler, and we don't have the real types - only type mirrors and elements.

Also, this P/R ups the method length (in lines) maximum as the current 150 is insufficient for the full code-gen methods. We could shorten them again with some refactoring, but that needs to be in another P/R I think.

This approach is a better alternative to the approach in #263, which used the loader of the module. By building from the entry-point, and using the requesting object's owning classloader, we get a path along a real chain of classloaders, and this chain has to match the classloader visibility rules, because otherwise this code would never be loadable in any case.