@@ -303,9 +303,7 @@ public static FileDescriptor buildFrom(FileDescriptorProto proto, FileDescriptor
303303 * two messages were defined with the same name.
304304 */
305305 public static FileDescriptor buildFrom (
306- FileDescriptorProto proto ,
307- FileDescriptor [] dependencies ,
308- boolean allowUnknownDependencies )
306+ FileDescriptorProto proto , FileDescriptor [] dependencies , boolean allowUnknownDependencies )
309307 throws DescriptorValidationException {
310308 // Building descriptors involves two steps: translating and linking.
311309 // In the translation step (implemented by FileDescriptor's
@@ -462,9 +460,9 @@ public static FileDescriptor internalBuildGeneratedFileFrom(
462460 }
463461
464462 /**
465- * This method is to be called by generated code only. It updates the
466- * FileDescriptorProto associated with the descriptor by parsing it again with the given
467- * ExtensionRegistry. This is needed to recognize custom options.
463+ * This method is to be called by generated code only. It updates the FileDescriptorProto
464+ * associated with the descriptor by parsing it again with the given ExtensionRegistry. This is
465+ * needed to recognize custom options.
468466 */
469467 public static void internalUpdateFileDescriptor (
470468 FileDescriptor descriptor , ExtensionRegistry registry ) {
@@ -1778,10 +1776,23 @@ public FileDescriptor getFile() {
17781776 * <p>Closed enum means that it:
17791777 *
17801778 * <ul>
1781- * <li>Has a fixed set of named values. *
1779+ * <li>Has a fixed set of values, rather than being equivalent to an int32.
17821780 * <li>Encountering values not in this set causes them to be treated as unknown fields.
17831781 * <li>The first value (i.e., the default) may be nonzero.
17841782 * </ul>
1783+ *
1784+ * <p>WARNING: Some runtimes currently have a quirk where non-closed enums are treated as closed
1785+ * when used as the type of fields defined in a `syntax = proto2;` file. This quirk is not
1786+ * present in all runtimes; as of writing, we know that:
1787+ *
1788+ * <ul>
1789+ * <li> C++, Java, and C++-based Python share this quirk.
1790+ * <li> UPB and UPB-based Python do not.
1791+ * <li> PHP and Ruby treat all enums as open regardless of declaration.
1792+ * </ul>
1793+ *
1794+ * <p>Care should be taken when using this function to respect the target runtime's enum
1795+ * handling quirks.
17851796 */
17861797 public boolean isClosed () {
17871798 return getFile ().getSyntax () != Syntax .PROTO3 ;
0 commit comments