iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/rmi/ir/InterfaceRepository.java
private ModuleDefImpl ensurePackageExists(LocalContainer c,
                                              String previous,
                                              String remainder)
            throws IRConstructionException {
        if ("".equals(remainder))
            return (ModuleDefImpl) c; // done

        int idx = remainder.indexOf('.');
        String base;

        if (idx == -1)
            base = remainder;
        else
            base = remainder.substring(0, idx);
        base = Util.javaToIDLName(base);

        if (previous.equals(""))
            previous = base;
        else
            previous = previous + "/" + base;
        if (idx == -1)
            remainder = "";
        else
            remainder = remainder.substring(idx + 1);

        LocalContainer next = null;
        LocalContained contained = (LocalContained) c._lookup(base);

        if (contained instanceof LocalContainer)
            next = (LocalContainer) contained;
        else if (contained != null)
            throw IIOPLogger.ROOT_LOGGER.collisionWhileCreatingPackage();

        if (next == null) {
            String id = "IDL:" + previous + ":1.0";

            // Create module
            ModuleDefImpl m = new ModuleDefImpl(id, base, "1.0", c, impl);

            c.add(base, m);

            if (idx == -1)
                return m; // done

            next = (LocalContainer) c._lookup(base); // Better be there now...
        } else // Check that next _is_ a module
            if (next.def_kind() != DefinitionKind.dk_Module)
                throw IIOPLogger.ROOT_LOGGER.collisionWhileCreatingPackage();

        return ensurePackageExists(next, previous, remainder);
    }
private ModuleDefImpl ensurePackageExists(LocalContainer c,
                                              String previous,
                                              String remainder)
            throws IRConstructionException {
        if ("".equals(remainder))
            return (ModuleDefImpl) c; // done

        int idx = remainder.indexOf('.');
        String base;

        if (idx == -1)
            base = remainder;
        else
            base = remainder.substring(0, idx);
        base = Util.javaToIDLName(base);

        if (previous.equals(""))
            previous = base;
        else
            previous = previous + "/" + base;
        if (idx == -1)
            remainder = "";
        else
            remainder = remainder.substring(idx + 1);

        LocalContainer next = null;
        LocalContained contained = (LocalContained) c._lookup(base);

        if (contained instanceof LocalContainer)
            next = (LocalContainer) contained;
        else if (contained != null)
            throw IIOPLogger.ROOT_LOGGER.collisionWhileCreatingPackage();

        if (next == null) {
            String id = "IDL:" + previous + ":1.0";

            // Create module
            ModuleDefImpl m = new ModuleDefImpl(id, base, "1.0", c, impl);

            c.add(base, m);

            if (idx == -1)
                return m; // done

            next = (LocalContainer) c._lookup(base); // Better be there now...
        } else // Check that next _is_ a module
            if (next.def_kind() != DefinitionKind.dk_Module)
                throw IIOPLogger.ROOT_LOGGER.collisionWhileCreatingPackage();

        return ensurePackageExists(next, previous, remainder);
    }
private ModuleDefImpl ensurePackageExists ( LocalContainer c , String previous , String remainder ) throws IRConstructionException { if ( "" . equals ( remainder ) ) return ( ModuleDefImpl ) c ; // done int idx = remainder . indexOf ( ' ' ) ; String base ; if ( idx == - 1 ) base = remainder ; else base = remainder . substring ( 0 , idx ) ; base = Util . javaToIDLName ( base ) ; if ( previous . equals ( "" ) ) previous = base ; else previous = previous + "/" + base ; if ( idx == - 1 ) remainder = "" ; else remainder = remainder . substring ( idx + 1 ) ; LocalContainer next = null ; LocalContained contained = ( LocalContained ) c . _lookup ( base ) ; if ( contained instanceof LocalContainer ) next = ( LocalContainer ) contained ; else if ( contained != null ) throw IIOPLogger . ROOT_LOGGER . collisionWhileCreatingPackage ( ) ; if ( next == null ) { String id = "IDL:" + previous + ":1.0" ; // Create module ModuleDefImpl m = new ModuleDefImpl ( id , base , "1.0" , c , impl ) ; c . add ( base , m ) ; if ( idx == - 1 ) return m ; // done next = ( LocalContainer ) c . _lookup ( base ) ; // Better be there now... } else // Check that next _is_ a module if ( next . def_kind ( ) != DefinitionKind . dk_Module ) throw IIOPLogger . ROOT_LOGGER . collisionWhileCreatingPackage ( ) ; return ensurePackageExists ( next , previous , remainder ) ; }
Ensure that a package exists in the IR.
This will create modules in the IR as needed.

@param c         The container that the remainder of modules should be defined in.
@param previous  The IDL module name, from root to <code>c</code>.
@param remainder The java package name, relative to <code>c</code>.
@return A reference to the IR module that represents the package.
Ensure that a package exists in the IR . This will create modules in the IR as needed .