Needed for issue #38306 - from the Ant module, I
need to load Ant tasks from a named module, using
a class loader derived from the module loader.
Using the SystemClassLoader is not really safe as
it is common for there to be multiple copies of
important libraries in the VM and you would have
no way of knowing which you were getting.
Proposed added API in o.o.m.ModuleInfo:
* Get a class loader associated with this module
* that can load classes defined in the module.
* You can only call this method on an enabled
* module, and the result may change if the module
* is disabled and reenabled.
* The class loader may or may not be shared with
* any other module, or be the application's
* startup class loader, etc.
* @return a module class loader
* @throws IllegalArgumentException if this module
* is disabled
public abstract ClassLoader getClassLoader();
o.n.c.m.Module would rename its current
getClassLoader to getClassLoaderOrNull and
implement this method to throw IAE as appropriate.
Note that the addition of an abstract method to
this class is not an incompatible API change since
it already forbids there to be subclasses except
See issue #38306 for branch information.
Actually it seems o.n.c.m.M.gCLOrNull is unnecessary - no one was
trying to call M.getClassLoader on a disabled module anyway.
Created attachment 12675 [details]
Requesting fast-track review. Simple compatible change. The method has
long existed internally in core; this just exposes it in the Open
APIs. No change needed to arch descs.
Correction: it seems autoupdate does in fact override ModuleInfo for
its own internal purposes (though it does not expose the instances
externally). So ModuleInfo.getClassLoader should not be abstract but
should instead throw UnsupportedOperationException in the default impl
- this will permit autoupdate to remain unchanged. Will make this
correction in the branch.
Planned for commit to trunk during the day (US time) on Wednesday.
committed * Up-To-Date 1.33 core/manifest.mf
committed * Up-To-Date 1.50
committed * Up-To-Date 1.129 openide/openide-spec-vers.properties
committed * Up-To-Date 1.182
committed * Up-To-Date 1.11