diff options
| author | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2005-10-13 20:58:53 +0000 |
|---|---|---|
| committer | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2005-10-13 20:58:53 +0000 |
| commit | 0c2f65348755a684fc5a50b0fbf83e4ed0052bdc (patch) | |
| tree | b239e5f3bce17764303c441daf718fd84f7901fd /gnu/CORBA/ObjectCreator.java | |
| parent | 41085b100a83d143e3e00350eb4eda7e9cc0136b (diff) | |
| download | classpath-0c2f65348755a684fc5a50b0fbf83e4ed0052bdc.tar.gz | |
2005-10-13 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* gnu/CORBA/ObjectCreator.java (forName):
Use gnu.classpath.VMStackWalker.
* gnu/CORBA/Interceptor/Registrator.java,
gnu/CORBA/gnuValueHolder.java,
gnu/CORBA/stubFinder.java,
gnu/javax/rmi/CORBA/DelegateFactory.java,
gnu/javax/rmi/CORBA/StubDelegateImpl.java,
org/omg/CORBA/ORB.java: Load class via ObjectCreator.
Diffstat (limited to 'gnu/CORBA/ObjectCreator.java')
| -rw-r--r-- | gnu/CORBA/ObjectCreator.java | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/gnu/CORBA/ObjectCreator.java b/gnu/CORBA/ObjectCreator.java index d6a102f54..50037edda 100644 --- a/gnu/CORBA/ObjectCreator.java +++ b/gnu/CORBA/ObjectCreator.java @@ -43,6 +43,7 @@ import gnu.CORBA.CDR.cdrBufInput; import gnu.CORBA.CDR.cdrBufOutput; import gnu.CORBA.CDR.cdrInput; import gnu.CORBA.GIOP.ServiceContext; +import gnu.classpath.VMStackWalker; import org.omg.CORBA.Any; import org.omg.CORBA.CompletionStatus; @@ -547,12 +548,42 @@ public class ObjectCreator } /** - * Load the class with the given name. + * Load the class with the given name. This method tries to use the context + * class loader first. If this fails, it searches for the suitable class + * loader in the caller stack trace. This method is a central point where all + * requests to find a class by name are delegated. */ - public static Class forName(String className) - throws ClassNotFoundException - { - return Class.forName(className, true, - Thread.currentThread().getContextClassLoader()); - } + public static Class forName(String className) throws ClassNotFoundException + { + try + { + return Class.forName(className, true, + Thread.currentThread().getContextClassLoader()); + } + catch (ClassNotFoundException nex) + { + /** + * Returns the first user defined class loader on the call stack, or + * null when no non-null class loader was found. + */ + Class[] ctx = VMStackWalker.getClassContext(); + for (int i = 0; i < ctx.length; i++) + { + // Since we live in a class loaded by the bootstrap + // class loader, getClassLoader is safe to call without + // needing to be wrapped in a privileged action. + ClassLoader cl = ctx[i].getClassLoader(); + try + { + if (cl != null) + return Class.forName(className, true, cl); + } + catch (ClassNotFoundException nex2) + { + // Try next. + } + } + } + throw new ClassNotFoundException(className); + } }
\ No newline at end of file |
