Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add null to the list of reserved words. #16784

Merged
1 commit merged into from
May 9, 2024
Merged

Add null to the list of reserved words. #16784

1 commit merged into from
May 9, 2024

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented May 8, 2024

Add null to the list of reserved words.

The previous change claimed to do this in addition to true and false, but it was not actually in the code.

To reiterate the text from the earlier change, now actually reflected entirely in the code:

The identifiers true, false, and null are effectively reserved words in Java, although for some reason they are listed separately from the "keywords" in the Java Language Specification.

This doesn't matter for regular fields, because a proto field called true will be accessed with getTrue and setTrue. But for extensions, the generated Java code will have a public static field whose name is the same as the name of the extension field, with _ appended if the name is a reserved word. Previously there was no _ for true etc, so the generated code would not compile.

This change should not affect any existing client code in Java. If someone had tried to use an extension called true (etc), they would have found that the generated proto code did not compile. Now it is possible to reference such an extension as true_.

The previous change claimed to do this in addition to `true` and `false`, but it was not actually in the code.

To reiterate the text from the earlier change, now actually reflected entirely in the code:

> The identifiers `true`, `false`, and `null` are effectively reserved words in Java, although for some reason they are listed separately from the "keywords" in the Java Language Specification.
>
> This doesn't matter for regular fields, because a proto field called `true` will be accessed with `getTrue` and `setTrue`. But for extensions, the generated Java code will have a public static field whose name is the same as the name of the extension field, with `_` appended if the name is a reserved word. Previously there was no `_` for `true` etc, so the generated code would not compile.

This change should not affect any existing client code in Java. If someone had tried to use an extension called `true` (etc), they would have found that the generated proto code did not compile. Now it is possible to reference such an extension as `true_`.

PiperOrigin-RevId: 632174190
@copybara-service copybara-service bot closed this pull request by merging all changes into main in 510c143 May 9, 2024
@copybara-service copybara-service bot deleted the test_631786175 branch May 9, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant