This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 38330

Summary: Add ModuleInfo.getClassLoader()
Product: platform Reporter: Jesse Glick <jglick>
Component: Module SystemAssignee: Jesse Glick <jglick>
Status: RESOLVED FIXED    
Severity: blocker CC: apireviews
Priority: P2 Keywords: API, API_REVIEW_FAST
Version: 3.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on:    
Bug Blocks: 38306    
Attachments: Proposed patch

Description Jesse Glick 2003-12-26 01:36:25 UTC
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
in core.
Comment 1 Jesse Glick 2003-12-26 01:39:05 UTC
See issue #38306 for branch information.
Comment 2 Jesse Glick 2003-12-26 02:11:56 UTC
Actually it seems o.n.c.m.M.gCLOrNull is unnecessary - no one was
trying to call M.getClassLoader on a disabled module anyway.
Comment 3 Jesse Glick 2003-12-26 02:13:56 UTC
Created attachment 12675 [details]
Proposed patch
Comment 4 Jesse Glick 2003-12-26 02:19:11 UTC
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.
Comment 5 Jesse Glick 2003-12-26 03:25:20 UTC
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.
Comment 6 Jesse Glick 2004-01-06 16:34:05 UTC
Planned for commit to trunk during the day (US time) on Wednesday.
Comment 7 Jesse Glick 2004-01-07 22:08:08 UTC
committed   * Up-To-Date  1.33        core/manifest.mf
committed   * Up-To-Date  1.50       
core/src/org/netbeans/core/modules/Module.java
committed   * Up-To-Date  1.129       openide/openide-spec-vers.properties
committed   * Up-To-Date  1.182      
openide/api/doc/changes/apichanges.xml
committed   * Up-To-Date  1.11       
openide/src/org/openide/modules/ModuleInfo.java