[jboss-dev] How to get bootstrap classloader

Jason T. Greene jason.greene at redhat.com
Wed Apr 30 12:57:04 EDT 2008


That won't work. It actually gives you the ext class loader. The 
bootstrap classloader isn't required to actually exist. It doesn't on 
the Sun JVM. Instead its actually just a classpath, that is checked 
statically by ClassLoader.

So, basically, there is no reliable way to get classes in the bootstrap. 
You don't need to do this though. All you need to do is create your own 
classloader, that has the same lifespan as AOP. Then if 
class.getClassLoader == null, you use that global CL.

Julien Viet wrote:
> Hi Kabir,
> 
> this should work
> 
> ClassLoader.getSystemClassLoader().getParent()
> 
> 
> On Apr 30, 2008, at 1:43 PM, Kabir Khan wrote:
> 
>> I need to generate a proxy for java.util.ArrayList using the same 
>> classloader that java.util.ArrayList uses. The problem is that:
>>
>>   ArrayList.class.getClassLoader() == null
>>
>> since it is the bootstrap classloader. I can think of a few ways to 
>> get hold of the actual loader, but wondered if somebody knows an 
>> elegant/obvious way to get hold of the clasloader?
>>
>>
>> -- 
>> Kabir Khan
>> JBoss AOP Lead
>> JBoss, a division of Red Hat
>>
>> _______________________________________________
>> jboss-development mailing list
>> jboss-development at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/jboss-development
> 
> _______________________________________________
> jboss-development mailing list
> jboss-development at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-development


-- 
Jason T. Greene
JBoss, a division of Red Hat



More information about the jboss-development mailing list