Issue 1696: Proposed change to orb.init (java-rtf) Source: (, ) Nature: Uncategorized Issue Severity: Summary: Summary: How should ORB.init() be fixed? ORB.init() should try to find an ORB class in the following order: 1. Try loading the class using Class.forName(String className) -- this is to take into account the possibility that the ORB implementation class is in the core (for example: com.sun.CORBA.iiop.ORB). If that fails, 2. Try loading the class using Class.forName(String className, boolean initialize, ClassLoader cl), where cl == ClassLoader.getSystemClassLoader(). In the case of an applet, cl == applet.getClass().getClassLoader(). For sophisticated users who might have a well-behaved ClassLoader that knows how to load the ORB implementation, it might be necessary to have a new ORB.init() that takes a ClassLoader as an argument. For example: ORB.init(String[] args, Properties props, ClassLoader cl); In this case, ORB.init() would load the class using the class loader that was passed by the user instead of the system class loader. Resolution: closed issue Revised Text: Actions taken: July 20, 1998: received issue February 23, 1999: closed issue Discussion: End of Annotations:===== Return-Path: Date: Fri, 17 Jul 1998 22:57:27 +0100 From: Simon Nash Reply-To: nash@hursley.ibm.com Organization: IBM To: java-rtf@omg.org Cc: issues@omg.org Subject: Proposed change to orb.init We discussed this briefly on Thursday's call. As promised, I am attaching a written proposal from Sun explaining why this is needed and how it would work. Simon -- Simon C Nash, IBM Java Technology Centre, Hursley, UK MailPoint 146, x245156 Tel. 01962 815156 or +44-1962-815156 Internet: nash@hursley.ibm.com Notes mail: Simon Nash@ibmgb ORB.init() -- Behaviour Change Background JDK1.2 has made a distinction in class loading by having the following types of class loaders: * Bootstrap class loader * System class loader (also called as the application class loader) Bootstrap Class Loader All classes in rt.jar are loaded by the bootstrap class loader. Stated differently, the bootstrap class loader will only load the classes from rt.jar. -Xbootclasspath can be used to replace rt.jar but the use of -Xbootclasspath is discouraged. System Class Loader The system class loader looks at the system property java.class.path (which is either the value specified using -classpath or the CLASSPATH environment variable) for classes after trying to load the class using the bootstrap class loader. Class.forName There are two Class.forName's in JDK1.2: * Class.forName(String className) * Class.forName(String className, boolean initialize, ClassLoader cl) How does this relate to ORB.init()? All classes in the package org.omg.CORBA are in rt.jar. The ORB API -- org.omg.CORBA.ORB.init() -- uses Class.forName(String className)to load the ORB implementation class. Class.forName(String className) loads classes using its caller's class loader, which in this case is the bootstrap class loader. Because the bootstrap class loader will only load classes from rt.jar, it becomes impossible to load ORB implementation classes which are not in rt.jar (unless -Xbootclasspath is used on every invocation of java to work around this problem). How should ORB.init() be fixed? ORB.init() should try to find an ORB class in the following order: 1. Try loading the class using Class.forName(String className) -- this is to take into account the possibility that the ORB implementation class is in the core (for example: com.sun.CORBA.iiop.ORB). If that fails, 2. Try loading the class using Class.forName(String className, boolean initialize, ClassLoader cl), where cl == ClassLoader.getSystemClassLoader(). In the case of an applet, cl == applet.getClass().getClassLoader(). For sophisticated users who might have a well-behaved ClassLoader that knows how to load the ORB implementation, it might be necessary to have a new ORB.init() that takes a ClassLoader as an argument. For example: ORB.init(String[] args, Properties props, ClassLoader cl); In this case, ORB.init() would load the class using the class loader that was passed by the user instead of the system class loader.