Skip to content

Commit 2c8fd4f

Browse files
Update java-proto-names to mention Edition 2024 better defaults.
PiperOrigin-RevId: 820783382
1 parent 21f0b45 commit 2c8fd4f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

content/reference/java/java-proto-names.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ package you need to import to use that message.
1212

1313
## Recommendation { #recommendation }
1414

15+
Starting with Edition 2024, best practice is to:
16+
17+
* Set `option java_package = "com.example.package"`
18+
* **Do not set** `java_outer_classname` or
19+
`features.(pb.java).nest_in_file_class = YES`.
20+
21+
Starting with Edition 2024, the default behaviors have otherwise been improved
22+
so that now the default behavior is considered current best practice.
23+
24+
When using Proto2, Proto3, or Edition 2023, best practice is to:
25+
1526
* Set `option java_multiple_files = true;`
1627
* Set `option java_outer_classname = "FileNameProto";`
1728
* Set `option java_package = "com.google.package";`
@@ -24,6 +35,10 @@ With `java_multiple_files = true`, the generated Java class for each message
2435
will be placed in a separate `.java` file. This makes it much easier to move
2536
messages from one `.proto` file to another.
2637

38+
Starting in Edition 2024 this has been replaced by the feature
39+
`features.(pb.java).nest_in_file_class` which has default value of `NO`,
40+
matching the `java_multiple_files = true` behavior in older syntax.
41+
2742
#### Outer Classname {#outer-classname}
2843

2944
There is a Java class generated for the `.proto` file itself. The name of the
@@ -38,6 +53,10 @@ The best policy is to explicitly set the `java_outer_classname` option to the
3853
option java_outer_classname = "StudentRecordRequestProto";
3954
```
4055
56+
Starting in Edition 2024, `java_outer_classname` is still available, but the
57+
default behavior has been changed to match this recommendation and so does not
58+
need to be set.
59+
4160
#### Java Package {#java-package}
4261
4362
The Java package for generated bindings will be automatically set to the proto

0 commit comments

Comments
 (0)