@@ -886,15 +886,20 @@ proto2 | `LEGACY`
886886
887887**Languages:** Java
888888
889- This language-specific feature enables you to adopt new functionality that
890- handles large enums in Java without causing compiler errors. Note that this
891- feature replicates enum-like behavior but has some notable differences. For
892- example, switch statements are not supported.
889+ When enabled, the Java code generator emits an enum-like class that doesn't
890+ extend `java.lang.Enum`, so enums with many values don't hit Java compiler and
891+ classfile limits.
892+
893+ The generated class implements `ProtocolMessageEnum` (or `Internal.EnumLite` for
894+ the lite runtime). Note that this feature replicates enum-like behavior but has
895+ some notable differences: Java `switch` statements on the enum type and
896+ `EnumSet`/`EnumMap` are not supported, and the enum must be an
897+ [open enum](#enum_type) (`features.enum_type = CLOSED` is not allowed).
893898
894899**Values available:**
895900
896- * `true`: Java enums will use the new functionality .
897- * `false`: Java enums will continue to use Java enums .
901+ * `true`: Generates an enum-like final class instead of a `java.lang.Enum` .
902+ * `false`: Generates a standard Java `enum` .
898903
899904**Applicable to the following scopes:** file, enum
900905
@@ -913,6 +918,28 @@ proto2 | `false`
913918**Note:** Feature settings on different schema elements
914919[have different scopes](#cascading).
915920
921+ To enable `large_enum` on an enum definition:
922+
923+ ```proto
924+ edition = "2024";
925+
926+ import option "google/protobuf/java_features.proto";
927+
928+ enum MyLargeEnum {
929+ option features.(pb.java).large_enum = true;
930+
931+ MY_LARGE_ENUM_UNSPECIFIED = 0;
932+ // ...
933+ }
934+ ```
935+
936+ In Edition 2026 and later, enums with more than 1,700 values must also set
937+ ` option features.enforce_proto_limits = LEGACY_NO_EXPLICIT_LIMITS; ` on the enum
938+ (see [ ` features.enforce_proto_limits ` ] ( #enforce_proto_limits ) ). Excessively
939+ large enums can also cause problems in other programming languages, but Java has
940+ the lowest underlying language limit, which is why ` enforce_proto_limits ` limits
941+ enums to 1,700 values.
942+
916943### ` features.(pb.cpp/pb.java).legacy_closed_enum ` {#legacy_closed_enum}
917944
918945** Languages:** C++, Java
0 commit comments