java_features.proto 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2023 Google Inc. All rights reserved.
  3. //
  4. // Use of this source code is governed by a BSD-style
  5. // license that can be found in the LICENSE file or at
  6. // https://developers.google.com/open-source/licenses/bsd
  7. syntax = "proto2";
  8. package pb;
  9. import "google/protobuf/descriptor.proto";
  10. option java_package = "com.google.protobuf";
  11. option java_outer_classname = "JavaFeaturesProto";
  12. extend google.protobuf.FeatureSet {
  13. optional JavaFeatures java = 1001;
  14. }
  15. message JavaFeatures {
  16. // Whether or not to treat an enum field as closed. This option is only
  17. // applicable to enum fields, and will be removed in the future. It is
  18. // consistent with the legacy behavior of using proto3 enum types for proto2
  19. // fields.
  20. optional bool legacy_closed_enum = 1 [
  21. retention = RETENTION_RUNTIME,
  22. targets = TARGET_TYPE_FIELD,
  23. targets = TARGET_TYPE_FILE,
  24. feature_support = {
  25. edition_introduced: EDITION_2023,
  26. edition_deprecated: EDITION_2023,
  27. deprecation_warning: "The legacy closed enum behavior in Java is "
  28. "deprecated and is scheduled to be removed in "
  29. "edition 2025. See http://protobuf.dev/programming-guides/enum/#java for "
  30. "more information.",
  31. },
  32. edition_defaults = { edition: EDITION_LEGACY, value: "true" },
  33. edition_defaults = { edition: EDITION_PROTO3, value: "false" }
  34. ];
  35. // The UTF8 validation strategy to use.
  36. enum Utf8Validation {
  37. // Invalid default, which should never be used.
  38. UTF8_VALIDATION_UNKNOWN = 0;
  39. // Respect the UTF8 validation behavior specified by the global
  40. // utf8_validation feature.
  41. DEFAULT = 1;
  42. // Verifies UTF8 validity overriding the global utf8_validation
  43. // feature. This represents the legacy java_string_check_utf8 option.
  44. VERIFY = 2;
  45. }
  46. optional Utf8Validation utf8_validation = 2 [
  47. retention = RETENTION_RUNTIME,
  48. targets = TARGET_TYPE_FIELD,
  49. targets = TARGET_TYPE_FILE,
  50. feature_support = {
  51. edition_introduced: EDITION_2023,
  52. edition_deprecated: EDITION_2024,
  53. deprecation_warning: "The Java-specific utf8 validation feature is "
  54. "deprecated and is scheduled to be removed in "
  55. "edition 2025. Utf8 validation behavior should "
  56. "use the global cross-language utf8_validation "
  57. "feature.",
  58. },
  59. edition_defaults = { edition: EDITION_LEGACY, value: "DEFAULT" }
  60. ];
  61. // Allows creation of large Java enums, extending beyond the standard
  62. // constant limits imposed by the Java language.
  63. optional bool large_enum = 3 [
  64. retention = RETENTION_RUNTIME,
  65. targets = TARGET_TYPE_ENUM,
  66. targets = TARGET_TYPE_FILE,
  67. feature_support = {
  68. edition_introduced: EDITION_2024,
  69. },
  70. edition_defaults = { edition: EDITION_LEGACY, value: "false" }
  71. ];
  72. // Whether to use the old default outer class name scheme, or the new feature
  73. // which adds a "Proto" suffix to the outer class name.
  74. //
  75. // Users will not be able to set this option, because we removed it in the
  76. // same edition that it was introduced. But we use it to determine which
  77. // naming scheme to use for outer class name defaults.
  78. optional bool use_old_outer_classname_default = 4 [
  79. retention = RETENTION_RUNTIME,
  80. targets = TARGET_TYPE_FILE,
  81. feature_support = {
  82. edition_introduced: EDITION_2024,
  83. edition_removed: EDITION_2024,
  84. },
  85. edition_defaults = { edition: EDITION_LEGACY, value: "true" },
  86. edition_defaults = { edition: EDITION_2024, value: "false" }
  87. ];
  88. message NestInFileClassFeature {
  89. enum NestInFileClass {
  90. // Invalid default, which should never be used.
  91. NEST_IN_FILE_CLASS_UNKNOWN = 0;
  92. // Do not nest the generated class in the file class.
  93. NO = 1;
  94. // Nest the generated class in the file class.
  95. YES = 2;
  96. // Fall back to the `java_multiple_files` option. Users won't be able to
  97. // set this option.
  98. LEGACY = 3 [feature_support = {
  99. edition_introduced: EDITION_2024
  100. edition_removed: EDITION_2024
  101. }];
  102. }
  103. reserved 1 to max;
  104. }
  105. // Whether to nest the generated class in the generated file class. This is
  106. // only applicable to *top-level* messages, enums, and services.
  107. optional NestInFileClassFeature.NestInFileClass nest_in_file_class = 5 [
  108. retention = RETENTION_SOURCE,
  109. targets = TARGET_TYPE_MESSAGE,
  110. targets = TARGET_TYPE_ENUM,
  111. targets = TARGET_TYPE_SERVICE,
  112. feature_support = {
  113. edition_introduced: EDITION_2024,
  114. },
  115. edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY" },
  116. edition_defaults = { edition: EDITION_2024, value: "NO" }
  117. ];
  118. }