[jboss-dev-forums] [Design of AOP on JBoss (Aspects/JBoss)] - Re: Reimplementing ClassPools for AS
kabir.khan@jboss.com
do-not-reply at jboss.com
Tue Jan 13 10:59:29 EST 2009
"adrian at jboss.org" wrote : I've uploaded a 2.0.2-SNAPSHOT of jboss-cl for you to try.
|
| This has a Module.getModuleForClass() which at least for our classloader implementation
| doesn't load the class.
Doesn't this load the class? From Module.java
| /**
| * Find the module that loads a class
| *
| * @param className the class name
| * @return the module or null if the class is not loaded by a registered module classloader
| * @throws ClassNotFoundException when the class is not found
| * @throws IllegalStateException when the module is not associated with a classloader
| */
| public Module getModuleForClass(String className) throws ClassNotFoundException
| {
| SecurityManager sm = System.getSecurityManager();
| if (sm != null)
| sm.checkPermission(new RuntimePermission("getClassLoader"));
|
| ClassLoader cl = getClassLoaderForClass(className);
|
| // Determine the module (if any) for the classloader
| if (cl != null)
| return modulesByClassLoader.get(cl);
| // Unknown
| return null;
| }
|
| /**
| * Get the classloader for a class name
| *
| * @param className the class name
| * @return the class
| * @throws ClassNotFoundException when the class is not found
| * @throws IllegalStateException when the module is not associated with a classloader
| */
| protected ClassLoader getClassLoaderForClass(String className) throws ClassNotFoundException
| {
| // Determine the classloader for this class
| final Class<?> clazz = loadClass(className);
| SecurityManager sm = System.getSecurityManager();
| if (sm != null)
| {
| return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
| {
| public ClassLoader run()
| {
| return clazz.getClassLoader();
| }
| });
| }
| return clazz.getClassLoader();
| }
|
| /**
| * Load a class for this module
| *
| * @param className the class name
| * @return the class
| * @throws ClassNotFoundException when the class is not found
| * @throws IllegalStateException when the module is not associated with a classloader
| */
| public Class<?> loadClass(String className) throws ClassNotFoundException
| {
| ClassLoader classLoader = getClassLoader();
| if (classLoader == null)
| throw new IllegalStateException("No classloader for this module " + this);
| return classLoader.loadClass(className);
| }
|
Or does the uploaded snapshot have a different impl?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4201436#4201436
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4201436
More information about the jboss-dev-forums
mailing list