-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.0
-
generic
-
generic
Name: krT82822 Date: 04/21/99
I'm having trouble using a JavaIDL client against and Orbix MT 2.3c or 2.3c02 server (compiled with Sun C++ version 4.2).
This problem does not occur if I use OrbixWeb 3.0.2 or VisiBroker for Java 3.3 with JDK 1.1.7 on the client side.
It also does not occur with Visibroker 3.3 or a Java ORB on the server side.
I am using idltojava which identifies itself as version Java IDL 1.2 created on Aug 11 1998 02:00:18
I will attach a simple IDL file, client program (Java) and server program (C++) which demonstrate the problem.
The problem is that if I have a Reference of type Object to a server object of derived interface C, I can not narrow it to a reference to the parent interface type B.
I will send a similar report to IONA, as I am unable to determine for certain whether the bug is in your software or theirs. I suspect it is in the Java2 implementation of org.omg.CORBA.Object._is_a() though :-(
To illustrate the bug:
generate java stubs for the IDL: idltojava A.idl
compile the java client: javac Client.java // this compiles the necessary stub files, too.
generate C++ skeletons: idl -B A.idl // -B to generate BOAImpl classes
compile C++: CC -o Server -I$ORBIX_ROOT/inc -mt -DREENTRANT Server.cc AS.cc -L$ORBIX_ROOT/lib -lITinimt -lorbixmt -lsocket
run the server:
% ./Server
about to call impl_is_ready
[narrow_bug_server: New Connection (callistemon.dsto.defence.gov.au,IT_daemon,*,sbd,pid=9721,optimised) ]
[narrow_bug_server: Server "narrow_bug_server" is now available to the network ]
[ Configuration tcp/1598/cdr ]
Called impl_is_ready with 0 timeout to make IORs valid
C IOR is IOR:000000200000000c49444c3a412f433a312e300000000001000000000000006f000100580000002063616c6c697374656d6f6e2e6473746f2e646566656e63652e676f762e617500063e73740000003f3a5c63616c6c697374656d6f6e2e6473746f2e646566656e63652e676f762e61753a6e6172726f775f6275675f7365727665723a303a3a49523a415f43003a
run the client in another window, with the server IOR on the commandline:
% java Client IOR:000000200000000c49444c3a412f433a312e300000000001000000000000006f000100580000002063616c6c697374656d6f6e2e6473746f2e646566656e63652e676f762e617500063e73740000003f3a5c63616c6c697374656d6f6e2e6473746f2e646566656e63652e676f762e61753a6e6172726f775f6275675f7365727665723a303a3a49523a415f43003a
Successfully narrowed to type C:
Failed to narrow to B
org.omg.CORBA.BAD_PARAM: minor code: 0 completed: No
Successfully narrowed C to type B:
The BAD_PARAM exception appears to be thrown in BHelper.narrow() after the call to Object._is_a().
=====
A.idl
=====
//This is a trivial IDL to attempt to identify whether the bug is in Orbix
//or JavaIDL
module A
{
interface B {
} ;
interface C:B {
} ;
} ;
===========
Client.java
===========
import org.omg.CORBA.*;
import A.*;
public class Client
{
/** Single argument is the IOR of the server */
public static void main(String args[]) {
if (args.length < 1) {
System.out.println("Usage: java Client <ior>");
System.exit(1);
}
ORB orb = ORB.init(args, null);
org.omg.CORBA.Object obj = orb.string_to_object(args[0]);
C c = null;
try {
c = CHelper.narrow(obj);
System.out.println("Successfully narrowed to type C: ");
}
catch (SystemException se) {
System.out.println("Failed to narrow to C");
System.out.println(se);
}
try {
B b = BHelper.narrow(obj);
System.out.println("Successfully narrowed to type B: ");
}
catch (SystemException se) {
System.out.println("Failed to narrow to B");
System.out.println(se);
}
try {
B b = BHelper.narrow(c);
System.out.println("Successfully narrowed C to type B: ");
}
catch (SystemException se) {
System.out.println("Failed to narrow C to B");
System.out.println(se);
}
}
}
=========
Server.cc
=========
#define USE_INIT
#include "A.hh"
#include <stream.h>
// Simple main program to explore possibly narrow() bug between JavaIDL
// client and Orbix server.
/** A reference to The ORB (so that objects can call orb->object_to_string())
*/
ORB_ptr orb;
class C_i : public virtual A::CBOAImpl {
};
/** A main program.
*/
int main(int argc, char **argv)
{
char *serviceName = "narrow_bug_server"; // the name for the server
long timeout = CORBA::Orbix.DEFAULT_TIMEOUT;
// connect to the ORB
orb = CORBA::ORB_init(argc, argv, "Orbix");
BOA_ptr boa = orb->BOA_init(argc, argv, "Orbix_BOA");
// make sure the real port is included in any IORs returned
CORBA::Orbix.useTransientPort(1);
// create an object
C_ptr c = new C_i();
try {
cout << "about to call impl_is_ready" << endl;
CORBA::Orbix.impl_is_ready(serviceName, 0L);
cout << "Called impl_is_ready with 0 timeout to make IORs valid" << endl;
cout << "C IOR is " << orb->object_to_string(c) << endl;
CORBA::Orbix.impl_is_ready(serviceName);
}
catch ( CORBA::SystemException& se) {
cerr << "Unexpected System Exception: " << &se << endl;
}
catch (...) {
cerr << "Failed to declare implementation ready" << endl;
cerr << "Unexpected Exception" << endl;
}
cout << "Server exiting" << endl;
return 0;
}
(Review ID: 57293)
======================================================================