[omniORB] Recursive Structures and JDK

Michael Sommerville msommer@ptc.com
Tue, 8 Feb 2000 13:46:30 -0000


Hi,

I am guessing this is no fault of omniORB but I have been having
problems with Sun JDK accessing a recursive structure (supplied
as an out function) defined as follows:

struct Folder
{
    string           name;
    string           full_path;
    sequence<Folder> sub_folders;
};

An omniORB test client prints the structure just fine, but
the client dies with a stack overflow (this happens with jdk1.2
on both Sun and WinNT).

Exception in thread "main" java.lang.StackOverflowError
        at com.sun.CORBA.idl.TypeCodeImpl.get_primitive_tc(Compiled Code)
        at com.sun.CORBA.idl.ORBSingleton.get_primitive_tc(Compiled Code)
        at FolderHelper.type(Compiled Code)
        at FolderHelper.type(Compiled Code)
        ..
        ..

Could anyone shed any light on this??  Is this a problem with the Java
ORB in 1.2?  In case it is something I'm doing wrong on the server side I've
hacked the relevant bits of functions out  of the server side code.  I've
tried versions where I explicitly set sub_folders length to be zero but I
guess
that should not be necessary.

I'm using omniORB 2.8.0.

Thanks for any assistance

Michael


void construct_folder(const char  *full_path, IlcFolder   *cfolder, Folder
*&folder )
{
    IlcFolder       *f;
    int                   n_folders = 0, fc = 0;

    f = cfolder;
    while(f)
    {
        n_folders++;
        f = f->next;
    }

    folder->sub_folders.length(n_folders);
    f = cfolder;
    while(f)
    {
        std::string      parent_name = full_path;
        parent_name += "/";
        parent_name += f->name;

        folder->sub_folders[fc].name = CORBA::string_dup(cfolder->name);
        folder->sub_folders[fc].full_path =
CORBA::string_dup(parent_name.c_str());
        // folder->sub_folders[fc].sub_folders.length(0);

        if (f->sub_folders)
        {
            Folder *sf =  &folder->sub_folders[fc];
            construct_folder(parent_name.c_str(), f->sub_folders, sf);
        }

        fc++;
        f = f->next;
    }
}

{
   ...
   ...
    folder = new Folder();
    folder->name = CORBA::string_dup("Root Folder");
    folder->full_path = CORBA::string_dup("Root Folder");
    construct_folder("Root Folder", il_folders->sub_folders, folder);
   ...
   ...

}