Skip to content

Fix Java ulong enum literal generation#9017

Open
steadytao wants to merge 1 commit intogoogle:masterfrom
steadytao:fix-8610-java-ulong-enum-literals
Open

Fix Java ulong enum literal generation#9017
steadytao wants to merge 1 commit intogoogle:masterfrom
steadytao:fix-8610-java-ulong-enum-literals

Conversation

@steadytao
Copy link
Copy Markdown

Summary

Emit Java ulong enum constants as signed long bit-equivalents instead of raw unsigned decimal literals.

Problem

For Java output, ulong enum values above Long.MAX_VALUE were emitted as decimal long literals such as:

public static final long None = 14695981039346656837L;

That does not compile in Java and fails with integer number too large.

Fix

  • convert Java ulong enum constants to their signed long bit-equivalent before emitting the literal
  • keep the generated type as long, which matches the existing Java representation for ulong
  • add a focused Java regression schema and test for ulong enum constants above Long.MAX_VALUE

Testing

  • reproduced the issue locally on current code generation
  • confirmed the pre-patch generated Java fails to compile with integer number too large
  • regenerated Java with the patch and confirmed it compiles cleanly
  • added a regression test that checks the generated constants against Long.parseUnsignedLong(..., 16)

Fixes #8610.

Emit Java ulong enum constants as signed long bit-equivalents so values above Long.MAX_VALUE compile correctly.

Add a focused Java ulong enum schema and regression test covering constants that previously failed with integer number too large.
@steadytao steadytao requested a review from dbaileychess as a code owner April 3, 2026 07:00
@github-actions github-actions bot added python java c++ codegen Involving generating code from schema labels Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ codegen Involving generating code from schema java python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support ulong in Java

1 participant