def _JImportFactory(spec, javaname, cls=_JImport):
    """ (internal) Factory for creating java modules dynamically.

    This is needed to create a new type node to hold static methods.
    """
    def init(self, name):
        # Call the base class
        cls.__init__(self, name)

    def getall(self):
        global _exportTypes
        d1 = self.__dict__.items()
        d2 = self.__class__.__dict__.items()
        local = [name for name, attr in d1 if not name.startswith('_')
                and isinstance(attr, _exportTypes)]
        glob = [name for name, attr in d2 if not name.startswith('_')
                and isinstance(attr, _exportTypes)]
        local.extend(glob)
        return local

    # Set up a new class for this type
    bases = [cls]
    members = {
        "__init__": init,
        "__javaname__": javaname,
        "__name__": spec.name,
        "__all__": property(getall),
        "__spec__": spec,
    }

    # Is this module also a class, if so insert class info
    jclass = _getJavaClass(javaname)
    if jclass:
        # Mark this as a class (will cause children to be inner classes)
        members['__javaclass__'] = jclass

        # Exposed static members as part of the module
        _copyProperties(members, jclass.__metaclass__)
        _copyStaticMethods(members, jclass)

    return type("module." + spec.name, tuple(bases), members)