Fix bugs in Java Large Enums that have aliased values.
The old implementation tried to emit only the canonical values in the 'chunked' ranges and then emit aliases separately at the top level, which led to a number of problems including: - On reflective lookup, it indexed into the values() array based on the all-value-index but that array only contained canonical-values. This is fixed to match the non-Large implementation where the public values() still returns only canonicals, but there's a second private array which contains all values for index-based indexing. - The static init dependency graph potentially had cycles which could leave values as null if they were touched in the 'wrong' order. This changes switches it to instead chunk up all enum values based on the original index range, unrelated to if they the value is an aliases or not. The non-aliases remain constructed as normal, the aliases are declared in their index-order but name the corresponding canonical value directly by its chunk (eg the SomeEnum2 chunk could have something like `public static final SomeEnum X_ALIAS = SomeEnum0.X`). Since the definition of alias is "the lowest index of a given value is the canonical one and any higher index with same value are aliases", this should avoid init cycles since the aliases will only point to some chunk which is <= its own chunk. PiperOrigin-RevId: 815717989
P
Protobuf Team Bot committed
3354a3c7ed6362010a00523ed11af258e8ef1049
Parent: a42e64f
Committed by Copybara-Service <copybara-worker@google.com>
on 10/6/2025, 2:34:52 PM