Repository navigation
Conversation
Changed the default implementation to use the system classloader, which is effectively a no-op. Moved the URLContextClassLoaderFactory to a test package for test visibility, updated tests.
| LOG.info("Using default {}, which is subject to change in a future release", | ||
| ContextClassLoaderFactory.class.getName()); | ||
| FACTORY = new URLContextClassLoaderFactory(); | ||
| FACTORY = new DefaultContextClassLoaderFactory(); |
There was a problem hiding this comment.
I suggest simplifying this logic by explicitly putting the classloader in the default value of the property, and failing if the class cannot be loaded. This reduces confusion about the default behavior due to "hidden" default property values (i.e. empty value results in undocumented internal default).
Alternatively, get rid of the class and use a lambda here when the property is empty:
| FACTORY = new DefaultContextClassLoaderFactory(); | |
| FACTORY = context -> ClassLoader.getSystemClassLoader(); |
There was a problem hiding this comment.
If an explicit implementation is kept for the default value of the property, then the name should not be "Default..." because that is the role, not the behavior. If the default changes, the name becomes misleading.
Instead, a name that reflects its behavior is better. Here are some AI-suggested names:
- SystemClassLoaderFactory — concise and clear, if the SPI context already makes the role obvious.
- SystemContextClassLoaderFactory — explicit about both the SPI and the classloader it returns.
- ContextIndependentClassLoaderFactory — emphasizes that the context argument is ignored, but not which loader is returned.
- FixedSystemClassLoaderFactory — conveys that it always returns the same system classloader.
- ConstantSystemClassLoaderFactory — similarly emphasizes the fixed result.
Of these, I'd lean towards the first or second.
Changed the default implementation to use the system classloader, which is effectively a no-op. Moved the URLContextClassLoaderFactory to a test package for test visibility, updated tests.