Automated rollback of commit a30b25578a0435c9c692f9a54b7b060a234dc6b3.

PiperOrigin-RevId: 643407401
diff --git a/editions/BUILD b/editions/BUILD
index 09838af..fd5dddd 100644
--- a/editions/BUILD
+++ b/editions/BUILD
@@ -87,18 +87,6 @@
     ],
 )
 
-cc_proto_library(
-    name = "cpp_features_cc_proto",
-    testonly = True,
-    deps = ["//src/google/protobuf:cpp_features_proto"],
-)
-
-cc_proto_library(
-    name = "java_features_cc_proto",
-    testonly = True,
-    deps = ["//java/core:java_features_proto"],
-)
-
 cc_test(
     name = "defaults_test",
     srcs = ["defaults_test.cc"],
@@ -109,11 +97,11 @@
         ":test_defaults_future",
     ],
     deps = [
-        ":cpp_features_cc_proto",
         ":defaults_test_embedded",
-        ":java_features_cc_proto",
         "//:protobuf",
+        "//java/core:java_features_cc_proto",
         "//src/google/protobuf",
+        "//src/google/protobuf:cpp_features_cc_proto",
         "//src/google/protobuf:port",
         "//src/google/protobuf:protobuf_lite",
         "//src/google/protobuf:test_textproto",
diff --git a/java/core/BUILD.bazel b/java/core/BUILD.bazel
index 7ca8a85..d695ab0 100644
--- a/java/core/BUILD.bazel
+++ b/java/core/BUILD.bazel
@@ -196,6 +196,12 @@
     deps = ["//:descriptor_proto"],
 )
 
+cc_proto_library(
+    name = "java_features_cc_proto",
+    visibility = ["//editions:__pkg__"],
+    deps = [":java_features_proto"],
+)
+
 filegroup(
     name = "java_features_proto_srcs",
     srcs = ["src/main/resources/google/protobuf/java_features.proto"],
diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel
index 97caa0e..0b2db2c 100644
--- a/src/google/protobuf/BUILD.bazel
+++ b/src/google/protobuf/BUILD.bazel
@@ -231,6 +231,12 @@
     deps = [":descriptor_proto"],
 )
 
+cc_proto_library(
+    name = "cpp_features_cc_proto",
+    visibility = ["//editions:__pkg__"],
+    deps = [":cpp_features_proto"],
+)
+
 ################################################################################
 # C++ Runtime Library
 ################################################################################
diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc
index 78e2832..dbfc5f8 100644
--- a/src/google/protobuf/compiler/cpp/helpers.cc
+++ b/src/google/protobuf/compiler/cpp/helpers.cc
@@ -1664,6 +1664,8 @@
            "third_party/protobuf/descriptor"},
           {"third_party/protobuf/cpp_features",
            "third_party/protobuf/cpp_features"},
+          {"third_party/java/protobuf/java_features",
+           "third_party/java/protobuf/java_features_bootstrap"},
           {"third_party/protobuf/compiler/plugin",
            "third_party/protobuf/compiler/plugin"},
           {"net/proto2/compiler/proto/profile",
diff --git a/src/google/protobuf/compiler/java/BUILD.bazel b/src/google/protobuf/compiler/java/BUILD.bazel
index 40cd4a5..f188e07 100644
--- a/src/google/protobuf/compiler/java/BUILD.bazel
+++ b/src/google/protobuf/compiler/java/BUILD.bazel
@@ -86,6 +86,7 @@
     srcs = ["java_features.pb.cc"],
     hdrs = ["java_features.pb.h"],
     strip_include_prefix = "/src",
+    visibility = ["//editions:__pkg__"],
     deps = [
         "//src/google/protobuf",
         "//src/google/protobuf:arena",
diff --git a/src/google/protobuf/compiler/java/generator.h b/src/google/protobuf/compiler/java/generator.h
index 53cb616..1c49b86 100644
--- a/src/google/protobuf/compiler/java/generator.h
+++ b/src/google/protobuf/compiler/java/generator.h
@@ -18,8 +18,8 @@
 #include <string>
 #include <vector>
 
-#include "google/protobuf/compiler/code_generator.h"
 #include "google/protobuf/compiler/java/java_features.pb.h"
+#include "google/protobuf/compiler/code_generator.h"
 #include "google/protobuf/descriptor.pb.h"
 #include "google/protobuf/port.h"
 
diff --git a/src/google/protobuf/compiler/java/internal_helpers.h b/src/google/protobuf/compiler/java/internal_helpers.h
index 607669b..720a34d 100644
--- a/src/google/protobuf/compiler/java/internal_helpers.h
+++ b/src/google/protobuf/compiler/java/internal_helpers.h
@@ -12,8 +12,8 @@
 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_INTERNAL_HELPERS_H__
 #define GOOGLE_PROTOBUF_COMPILER_JAVA_INTERNAL_HELPERS_H__
 
-#include "google/protobuf/compiler/java/generator.h"
 #include "google/protobuf/compiler/java/java_features.pb.h"
+#include "google/protobuf/compiler/java/generator.h"
 #include "google/protobuf/compiler/java/names.h"
 #include "google/protobuf/descriptor.h"
 #include "google/protobuf/descriptor.pb.h"
diff --git a/src/google/protobuf/compiler/java/kotlin_generator.h b/src/google/protobuf/compiler/java/kotlin_generator.h
index afc4085..a0d3681 100644
--- a/src/google/protobuf/compiler/java/kotlin_generator.h
+++ b/src/google/protobuf/compiler/java/kotlin_generator.h
@@ -12,8 +12,8 @@
 
 #include <string>
 
-#include "google/protobuf/compiler/code_generator.h"
 #include "google/protobuf/compiler/java/java_features.pb.h"
+#include "google/protobuf/compiler/code_generator.h"
 #include "google/protobuf/descriptor.pb.h"
 
 // Must be included last.