CLass.forName()
和Thread.currentThread().getContextClassLoader())
是否一样?这连接可能对你有用!http://www.jdon.com/jive/article.jsp?forum=91&thread=15456
和Thread.currentThread().getContextClassLoader())
是否一样?这连接可能对你有用!http://www.jdon.com/jive/article.jsp?forum=91&thread=15456
用Class cl = Class.forName("com.eco.Fuck.test2");实际上是使用the invoker's class loader,一般就是系统类装载器来装载类.
而Class.forName("com.eco.Fuck.test2",true,classloader);是用你参数中指定的"
classloader"来装载类.
Thread.currentThread().setContextClassLoader是用来设定环境ClassLoader的,但Class.forName又明确指定了使用哪个ClassLoader,所以Thread.currentThread().setContextClassLoader看起来没有起作用。
你试一下,注释Thread.currentThread().setContextClassLoader(classloader);
直接用Class cl = Class.forName("com.eco.Fuck.test2",true,classloader);
是否也是正常的?
或者使用
Thread.currentThread().setContextClassLoader(classloader);
然后再用类似
new com.eco.Fuck.test2()的方式直接加载类,是否也是正常的?
期待你的好消息。