problem with getConstructor()
Hi,
I have the following code segment originally:
/////////////////////////////////////
import org.omg.CORBA.ORB;
import java.lang.reflect.*;
import com.sun.corba.ee.impl.naming.cosnaming.TransientNameService;
private static ORB orb = null;
TransientNameService nameService = new TransientNameService((com.sun.corba.ee.spi.orb.ORB)orb);
////////////////////////////////////////
which has the packages defined at compile-time. Now I'd need to
change the code (with Java Reflection) to load the packages at
run-time (the packages won't be known at compile-time).
Here is the code segment I come with to use Java Reflection with
packages unknown at compile-time:
(two packages unkown at compile-time:
com.sun.corba.ee.impl.naming.cosnaming.TransientNameService
com.sun.corba.ee.spi.orb.ORB
)
/***************************/
Class TransientNameServiceClass = Class.forName("com.sun.corba.ee.impl.naming.cosnaming.TransientNameService");
Class ORBClass = Class.forName( "com.sun.corba.ee.spi.orb.ORB" );
Constructor TransientNameServiceConstructor = TransientNameServiceClass.getConstructor( ORBClass.getClass() ) ;
Object nameService = TransientNameServiceConstructors[0].newInstance( ORBClass.cast(orb) );
/***************************/
somehow the next to last statement call:
TransientNameServiceClass.getConstructor( ORBClass.getClass() )
throws "java.lang.NoSuchMethodException".
But if I call:
Constructor[] TransientNameServiceConstructors = TransientNameServiceClass.getConstructors();
and then go through the list of Constructors found and compare the
params, I could find the matching Constructor that has
ORBClass as the only param.
IS there anything wrong with my call to:
TransientNameServiceClass.getConstructor( ORBClass.getClass() )
Any help would be much apprecaited.
Thanks.
Jen

