diff --git a/editions/golden/editions_transform_proto2.proto b/editions/golden/editions_transform_proto2.proto index 260a8d26ae80..84807b6d59b2 100644 --- a/editions/golden/editions_transform_proto2.proto +++ b/editions/golden/editions_transform_proto2.proto @@ -15,7 +15,7 @@ edition = "2023"; package protobuf_editions_test; import "net/proto/proto1_features.proto"; -import "third_party/java/protobuf/java_features.proto"; +import "google/protobuf/java_features.proto"; import "google/protobuf/cpp_features.proto"; import "google/protobuf/editions/proto/editions_transform_proto3.proto"; diff --git a/java/core/BUILD.bazel b/java/core/BUILD.bazel index 6127b4c5ca87..41802133edf1 100644 --- a/java/core/BUILD.bazel +++ b/java/core/BUILD.bazel @@ -336,6 +336,7 @@ proto_library( deps = [ "//:any_proto", "//:descriptor_proto", + "//:java_features_proto", "//:lite_test_protos", "//:wrappers_proto", "//src/google/protobuf:generic_test_protos", diff --git a/java/core/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java index f4aa9ca3ba05..bba31786147a 100644 --- a/java/core/src/main/java/com/google/protobuf/Descriptors.java +++ b/java/core/src/main/java/com/google/protobuf/Descriptors.java @@ -94,7 +94,7 @@ static FeatureSetDefaults getJavaEditionDefaults() { if (javaEditionDefaults == null) { try { ExtensionRegistry registry = ExtensionRegistry.newInstance(); - registry.add(JavaFeaturesProto.java); + registry.add(JavaFeaturesProto.java_); setTestJavaEditionDefaults( FeatureSetDefaults.parseFrom( JavaEditionDefaults.PROTOBUF_INTERNAL_JAVA_EDITION_DEFAULTS.getBytes( @@ -679,7 +679,7 @@ FeatureSet inferLegacyProtoFeatures() { if (getEdition() == Edition.EDITION_PROTO2) { if (proto.getOptions().getJavaStringCheckUtf8()) { features.setExtension( - JavaFeaturesProto.java, + JavaFeaturesProto.java_, JavaFeatures.newBuilder() .setUtf8Validation(JavaFeatures.Utf8Validation.VERIFY) .build()); @@ -1320,7 +1320,7 @@ public boolean needsUtf8Check() { return true; } if (this.features - .getExtension(JavaFeaturesProto.java) + .getExtension(JavaFeaturesProto.java_) .getUtf8Validation() .equals(JavaFeatures.Utf8Validation.VERIFY)) { return true; @@ -1577,7 +1577,7 @@ public boolean legacyEnumFieldTreatedAsClosed() { } return getType() == Type.ENUM - && (this.features.getExtension(JavaFeaturesProto.java).getLegacyClosedEnum() + && (this.features.getExtension(JavaFeaturesProto.java_).getLegacyClosedEnum() || enumType.isClosed()); } diff --git a/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java b/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java index d64186ad7ad8..2ebdf71e75de 100644 --- a/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java +++ b/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java @@ -1158,7 +1158,7 @@ public void testLegacyInferProto2Utf8Validation() throws Exception { .setOptions(FileOptions.newBuilder().setJavaStringCheckUtf8(true)) .build(), new FileDescriptor[0]); - assertThat(file.features.getExtension(JavaFeaturesProto.java).getUtf8Validation()) + assertThat(file.features.getExtension(JavaFeaturesProto.java_).getUtf8Validation()) .isEqualTo(JavaFeaturesProto.JavaFeatures.Utf8Validation.VERIFY); } @@ -1178,8 +1178,8 @@ public void testProto2Defaults() { assertThat(features.getJsonFormat()) .isEqualTo(DescriptorProtos.FeatureSet.JsonFormat.LEGACY_BEST_EFFORT); - assertThat(features.getExtension(JavaFeaturesProto.java).getLegacyClosedEnum()).isTrue(); - assertThat(features.getExtension(JavaFeaturesProto.java).getUtf8Validation()) + assertThat(features.getExtension(JavaFeaturesProto.java_).getLegacyClosedEnum()).isTrue(); + assertThat(features.getExtension(JavaFeaturesProto.java_).getUtf8Validation()) .isEqualTo(JavaFeaturesProto.JavaFeatures.Utf8Validation.DEFAULT); } @@ -1198,8 +1198,8 @@ public void testProto3Defaults() { assertThat(features.getMessageEncoding()) .isEqualTo(DescriptorProtos.FeatureSet.MessageEncoding.LENGTH_PREFIXED); - assertThat(features.getExtension(JavaFeaturesProto.java).getLegacyClosedEnum()).isFalse(); - assertThat(features.getExtension(JavaFeaturesProto.java).getUtf8Validation()) + assertThat(features.getExtension(JavaFeaturesProto.java_).getLegacyClosedEnum()).isFalse(); + assertThat(features.getExtension(JavaFeaturesProto.java_).getUtf8Validation()) .isEqualTo(JavaFeaturesProto.JavaFeatures.Utf8Validation.DEFAULT); } diff --git a/java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto b/java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto index 3af9831d2930..fff2805e78e9 100644 --- a/java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto +++ b/java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto @@ -12,7 +12,10 @@ edition = "2023"; package proto2_test_check_utf8; -option features.utf8_validation = VERIFY; +import "google/protobuf/java_features.proto"; + +option features.utf8_validation = NONE; +option features.(pb.java).utf8_validation = VERIFY; option java_outer_classname = "TestCheckUtf8"; message StringWrapper { diff --git a/objectivec/Tests/unittest.proto b/objectivec/Tests/unittest.proto index 2239fe69286b..dc9546db7601 100644 --- a/objectivec/Tests/unittest.proto +++ b/objectivec/Tests/unittest.proto @@ -1109,11 +1109,11 @@ message TestNestedGroupExtensionOuter { repeated group Layer2RepeatedGroup = 2 { extensions 3 // NOTE: extension metadata is not supported due to targets such as - // `//third_party/protobuf_legacy_opensource/src:shell_scripts_test`, + // `//google/protobuf_legacy_opensource/src:shell_scripts_test`, // eee https://screenshot.googleplex.com/Axz2QD8nxjdpyFF //[metadata = { // NOTE: can't write type there due to some clever build gen code at - // http://google3/net/proto2/internal/BUILD;l=1247;rcl=411090862 + // http://google3/google/protobuf/BUILD;l=1247;rcl=411090862 // type: "objc.protobuf.tests.TestNestedGroupExtensionInnerExtension", // name: "inner", // }] diff --git a/src/google/protobuf/compiler/java/names.cc b/src/google/protobuf/compiler/java/names.cc index 6df146353c78..e1381c78ca20 100644 --- a/src/google/protobuf/compiler/java/names.cc +++ b/src/google/protobuf/compiler/java/names.cc @@ -39,17 +39,17 @@ const char* DefaultPackage(Options options) { bool IsReservedName(absl::string_view name) { static const auto& kReservedNames = *new absl::flat_hash_set({ - "abstract", "assert", "boolean", "break", "byte", - "case", "catch", "char", "class", "const", - "continue", "default", "do", "double", "else", - "enum", "extends", "false", "final", "finally", - "float", "for", "goto", "if", "implements", - "import", "instanceof", "int", "interface", "long", - "native", "new", "null", "package", "private", - "protected", "public", "return", "short", "static", - "strictfp", "super", "switch", "synchronized", "this", - "throw", "throws", "transient", "true", "try", - "void", "volatile", "while", + "abstract", "assert", "boolean", "break", "byte", + "case", "catch", "char", "class", "const", + "continue", "default", "do", "double", "else", + "enum", "extends", "false", "final", "finally", + "float", "for", "goto", "if", "implements", + "import", "instanceof", "int", "interface", "java", + "long", "native", "new", "null", "package", + "private", "protected", "public", "return", "short", + "static", "strictfp", "super", "switch", "synchronized", + "this", "throw", "throws", "transient", "true", + "try", "void", "volatile", "while", }); return kReservedNames.contains(name); } diff --git a/src/google/protobuf/edition_unittest.proto b/src/google/protobuf/edition_unittest.proto index fadde47d2968..81848b87e4fe 100644 --- a/src/google/protobuf/edition_unittest.proto +++ b/src/google/protobuf/edition_unittest.proto @@ -1254,11 +1254,11 @@ message TestNestedGroupExtensionOuter { message Layer2RepeatedGroup { extensions 3 // NOTE: extension metadata is not supported due to targets such as - // `//third_party/protobuf_legacy_opensource/src:shell_scripts_test`, + // `//google/protobuf_legacy_opensource/src:shell_scripts_test`, // eee https://screenshot.googleplex.com/Axz2QD8nxjdpyFF //[metadata = { // NOTE: can't write type there due to some clever build gen code at - // http://google3/net/proto2/internal/BUILD;l=1247;rcl=411090862 + // http://google3/google/protobuf/BUILD;l=1247;rcl=411090862 // type: "edition_unittest.TestNestedGroupExtensionInnerExtension", // name: "inner", // }] diff --git a/src/google/protobuf/unittest.proto b/src/google/protobuf/unittest.proto index 3d9dc3a7759a..7c65fb594f87 100644 --- a/src/google/protobuf/unittest.proto +++ b/src/google/protobuf/unittest.proto @@ -1226,11 +1226,11 @@ message TestNestedGroupExtensionOuter { repeated group Layer2RepeatedGroup = 2 { extensions 3 // NOTE: extension metadata is not supported due to targets such as - // `//third_party/protobuf_legacy_opensource/src:shell_scripts_test`, + // `//google/protobuf_legacy_opensource/src:shell_scripts_test`, // eee https://screenshot.googleplex.com/Axz2QD8nxjdpyFF //[metadata = { // NOTE: can't write type there due to some clever build gen code at - // http://google3/net/proto2/internal/BUILD;l=1247;rcl=411090862 + // http://google3/google/protobuf/BUILD;l=1247;rcl=411090862 // type: "protobuf_unittest.TestNestedGroupExtensionInnerExtension", // name: "inner", // }]