43 |
import gnu.CORBA.CDR.cdrBufOutput; |
import gnu.CORBA.CDR.cdrBufOutput; |
44 |
import gnu.CORBA.CDR.cdrInput; |
import gnu.CORBA.CDR.cdrInput; |
45 |
import gnu.CORBA.GIOP.ServiceContext; |
import gnu.CORBA.GIOP.ServiceContext; |
46 |
|
import gnu.classpath.VMStackWalker; |
47 |
|
|
48 |
import org.omg.CORBA.Any; |
import org.omg.CORBA.Any; |
49 |
import org.omg.CORBA.CompletionStatus; |
import org.omg.CORBA.CompletionStatus; |
548 |
} |
} |
549 |
|
|
550 |
/** |
/** |
551 |
* Load the class with the given name. |
* Load the class with the given name. This method tries to use the context |
552 |
|
* class loader first. If this fails, it searches for the suitable class |
553 |
|
* loader in the caller stack trace. This method is a central point where all |
554 |
|
* requests to find a class by name are delegated. |
555 |
*/ |
*/ |
556 |
public static Class forName(String className) |
public static Class forName(String className) throws ClassNotFoundException |
557 |
throws ClassNotFoundException |
{ |
558 |
{ |
try |
559 |
return Class.forName(className, true, |
{ |
560 |
Thread.currentThread().getContextClassLoader()); |
return Class.forName(className, true, |
561 |
} |
Thread.currentThread().getContextClassLoader()); |
562 |
|
} |
563 |
|
catch (ClassNotFoundException nex) |
564 |
|
{ |
565 |
|
/** |
566 |
|
* Returns the first user defined class loader on the call stack, or |
567 |
|
* null when no non-null class loader was found. |
568 |
|
*/ |
569 |
|
Class[] ctx = VMStackWalker.getClassContext(); |
570 |
|
for (int i = 0; i < ctx.length; i++) |
571 |
|
{ |
572 |
|
// Since we live in a class loaded by the bootstrap |
573 |
|
// class loader, getClassLoader is safe to call without |
574 |
|
// needing to be wrapped in a privileged action. |
575 |
|
ClassLoader cl = ctx[i].getClassLoader(); |
576 |
|
try |
577 |
|
{ |
578 |
|
if (cl != null) |
579 |
|
return Class.forName(className, true, cl); |
580 |
|
} |
581 |
|
catch (ClassNotFoundException nex2) |
582 |
|
{ |
583 |
|
// Try next. |
584 |
|
} |
585 |
|
} |
586 |
|
} |
587 |
|
throw new ClassNotFoundException(className); |
588 |
|
} |
589 |
} |
} |