summaryrefslogtreecommitdiffstats
path: root/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
diff options
context:
space:
mode:
authormikhnenko <[email protected]>2024-06-25 08:50:35 +0300
committermikhnenko <[email protected]>2024-06-25 09:00:27 +0300
commit509c9fc9e7b9c3b8be7307d72a4c966e5f9aa194 (patch)
tree4b8a6a44009906ac852e59efa0bc78bb12043a5b /contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
parent7688f2313619a39a60ef3c2734d8efbc49a0a6db (diff)
Update protobuf to 3.20.2 and pyprotobuf to 3.20.3
Если это pull-request что-то сломал, то: - если это тест с канонизацией и еще нет pr с переканонизацией, то переканонизируйте пожалуйста сами - проверьте, что тест не флапает - приходите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/createTicket?queue=DEVTOOLSSUPPORT) - там вам обязательно помогут 987be5ed151f827f7f292f32420470b04b71a91d
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc')
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc37
1 files changed, 24 insertions, 13 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
index 4c613af8ea4..3f1f058c9e7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
@@ -40,13 +40,13 @@
#include <unordered_set>
#include <vector>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/stringprintf.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/compiler/java/java_names.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/hash.h> // for hash<T *>
namespace google {
@@ -66,15 +66,27 @@ namespace {
const char* kDefaultPackage = "";
-// Names that should be avoided as field names.
-// Using them will cause the compiler to generate accessors whose names are
-// colliding with methods defined in base classes.
+// Names that should be avoided (in UpperCamelCase format).
+// Using them will cause the compiler to generate accessors whose names
+// collide with methods defined in base classes.
+// Keep this list in sync with specialFieldNames in
+// java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java
const char* kForbiddenWordList[] = {
- // message base class:
- "cached_size",
- "serialized_size",
// java.lang.Object:
- "class",
+ "Class",
+ // com.google.protobuf.MessageLiteOrBuilder:
+ "DefaultInstanceForType",
+ // com.google.protobuf.MessageLite:
+ "ParserForType",
+ "SerializedSize",
+ // com.google.protobuf.MessageOrBuilder:
+ "AllFields",
+ "DescriptorForType",
+ "InitializationErrorString",
+ // TODO(b/219045204): re-enable
+ // "UnknownFields",
+ // obsolete. kept for backwards compatibility of generated code
+ "CachedSize",
};
const std::unordered_set<TProtoStringType>* kReservedNames =
@@ -93,7 +105,7 @@ const std::unordered_set<TProtoStringType>* kReservedNames =
bool IsForbidden(const TProtoStringType& field_name) {
for (int i = 0; i < GOOGLE_ARRAYSIZE(kForbiddenWordList); ++i) {
- if (field_name == kForbiddenWordList[i]) {
+ if (UnderscoresToCamelCase(field_name, true) == kForbiddenWordList[i]) {
return true;
}
}
@@ -1049,8 +1061,7 @@ int GetExperimentalJavaFieldType(const FieldDescriptor* field) {
if (field->is_map()) {
if (!SupportUnknownEnumValue(field)) {
- const FieldDescriptor* value =
- field->message_type()->FindFieldByName("value");
+ const FieldDescriptor* value = field->message_type()->map_value();
if (GetJavaType(value) == JAVATYPE_ENUM) {
extra_bits |= kMapWithProto2EnumValue;
}