Descriptors.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:Beam 作者:
/**
 * Construct a {@code FileDescriptor}.
 *
 * @param proto The protocol message form of the FileDescriptor.
 * @param dependencies {@code FileDescriptor}s corresponding to all of
 * the file's dependencies.
 * @param allowUnknownDependencies If true, non-exist dependenncies will
 * be ignored and undefined message types will be replaced with a
 * placeholder type.
 *
 * @throws DescriptorValidationException {@code proto} is not a valid
 * descriptor. This can occur for a number of reasons, e.g. because a
 * field has an undefined type or because two messages were defined with
 * the same name.
 */
private static FileDescriptor buildFrom (
        final FileDescriptorProto proto, final FileDescriptor[] dependencies,
        final boolean allowUnknownDependencies)
        throws DescriptorValidationException {
    // Building descriptors involves two steps:  translating and linking.
    // In the translation step (implemented by FileDescriptor's
    // constructor), we build an object tree mirroring the
    // FileDescriptorProto's tree and put all of the descriptors into the
    // DescriptorPool's lookup tables.  In the linking step, we look up all
    // type references in the DescriptorPool, so that, for example, a
    // FieldDescriptor for an embedded message contains a pointer directly
    // to the Descriptor for that message's type.  We also detect undefined
    // types in the linking step.
    final DescriptorPool pool = new DescriptorPool (
            dependencies, allowUnknownDependencies);
    final FileDescriptor result = new FileDescriptor (
            proto, dependencies, pool, allowUnknownDependencies);
    result.crossLink ();
    return result;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号