1 16 package org.mortbay.util; 17 18 19 35 public class Loader 36 { 37 38 public static Class loadClass(Class loadClass,String name) 39 throws ClassNotFoundException 40 { 41 ClassNotFoundException cnfe=null; 42 ClassLoader loader=Thread.currentThread().getContextClassLoader(); 43 if (loader!=null) 44 { 45 try 46 { 47 return loader.loadClass(name); 48 } 49 catch (ClassNotFoundException e) 50 { 51 cnfe=e; 52 } 53 } 54 55 loader=loadClass.getClassLoader(); 56 if (loader!=null) 57 { 58 try 59 { 60 return loader.loadClass(name); 61 } 62 catch (ClassNotFoundException e) 63 { 64 if(cnfe==null)cnfe=e; 65 } 66 } 67 68 69 try 70 { 71 return Class.forName(name); 72 } 73 catch (ClassNotFoundException e) 74 { 75 if(cnfe==null)cnfe=e; 76 throw cnfe; 77 } 78 79 } 80 } 81 82 | Popular Tags |