I am not sure if this has been discovered before, but I noticed an issue when doing
dynamic class generation on UnfiedClassLoader3.
I have some code that basically does (in simplified pseudocode):
| if (!isLoadable(className, loader))
| generate(className, loader)
|
| ... some time later ....
|
| loader.loadClass(className);
|
|
This leads to the following events in RepositoryClassLoader when a class is generated:
1. Class is not found, add to blacklist
2. defineClass() is called by javassist (using method.setAccess())
3. loadClass is called, and CNFE is returned due to blacklist entry
Unfortunately defineClass() is final so there is no way to detect this condition within
the loader. So, currently I call clearBlacklists() directly on the loader. This, however,
is not very efficient because the entire list is being cleared instead of just the one
class that is being generated.
One possible solution, is that we could define an interface for dispatching defineClass
calls. The ClassLoader could then implement this interface, and take care of calling the
protected definceClass(), as well as perform any needed cleanup. Javassist would then
attempt the interface first, and failover to the normal reflective mechanism.
-Jason
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3986381#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...