[jboss-jira] [JBoss JIRA] (JGRP-1762) Util.loadClass(): do we use the correct ClassLoader ?
Bela Ban (JIRA)
issues at jboss.org
Sat Dec 21 04:13:33 EST 2013
[ https://issues.jboss.org/browse/JGRP-1762?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bela Ban updated JGRP-1762:
---------------------------
Forum Reference: https://sourceforge.net/p/javagroups/discussion/18795/thread/38137bd0/
> Util.loadClass(): do we use the correct ClassLoader ?
> -----------------------------------------------------
>
> Key: JGRP-1762
> URL: https://issues.jboss.org/browse/JGRP-1762
> Project: JGroups
> Issue Type: Task
> Reporter: Bela Ban
> Assignee: Bela Ban
> Fix For: 3.5
>
>
> Investigate whether the code below uses the right classloader. Perhaps we should try to get the classloader of the instances passed to us *before* attempting to use the calling thread's class loader ?
> The current code is:
> {noformat}
> public static Class loadClass(String classname, Class clazz) throws ClassNotFoundException {
> ClassLoader loader;
> try {
> loader=Thread.currentThread().getContextClassLoader();
> if(loader != null) {
> return loader.loadClass(classname);
> }
> }
> catch(Throwable t) {
> }
> if(clazz != null) {
> try {
> loader=clazz.getClassLoader();
> if(loader != null) {
> return loader.loadClass(classname);
> }
> }
> catch(Throwable t) {
> }
> }
> try {
> loader=ClassLoader.getSystemClassLoader();
> if(loader != null) {
> return loader.loadClass(classname);
> }
> }
> catch(Throwable t) {
> }
> throw new ClassNotFoundException(classname);
> }
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list