Skip to content

Commit dba2323

Browse files
authored
compiler: Remove enable_depreated option (#3541)
1 parent 5e36a8d commit dba2323

File tree

5 files changed

+17
-120
lines changed

5 files changed

+17
-120
lines changed

build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ subprojects {
133133
task.inputs.file "${rootProject.projectDir}/build.gradle"
134134
task.plugins {
135135
grpc {
136-
// To generate deprecated interfaces and static bindService method,
137-
// turn the enable_deprecated option to true below:
138-
option 'enable_deprecated=false'
139136
option 'noversion'
140137
}
141138
}

compiler/src/java_plugin/cpp/java_generator.cpp

Lines changed: 15 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -452,43 +452,11 @@ static void PrintBindServiceMethodBody(const ServiceDescriptor* service,
452452
Printer* p,
453453
bool generate_nano);
454454

455-
static void PrintDeprecatedDocComment(const ServiceDescriptor* service,
456-
std::map<string, string>* vars,
457-
Printer* p) {
458-
p->Print(
459-
*vars,
460-
"/**\n"
461-
" * This will be removed in the next release.\n"
462-
" * If your code has been using gRPC-java v0.15.0 or higher already,\n"
463-
" * the following changes to your code are suggested:\n"
464-
" * <ul>\n"
465-
" * <li> replace {@code extends/implements $service_name$}"
466-
" with {@code extends $service_name$ImplBase} for server side;</li>\n"
467-
" * <li> replace {@code $service_name$} with {@code $service_name$Stub} for client side;"
468-
"</li>\n"
469-
" * <li> replace usage of {@code $service_name$} with {@code $service_name$ImplBase};"
470-
"</li>\n"
471-
" * <li> replace usage of {@code Abstract$service_name$}"
472-
" with {@link $service_name$ImplBase};</li>\n"
473-
" * <li> replace"
474-
" {@code serverBuilder.addService($service_class_name$.bindService(serviceImpl))}\n"
475-
" * with {@code serverBuilder.addService(serviceImpl)};</li>\n"
476-
" * <li> if you are mocking stubs using mockito, please do not mock them.\n"
477-
" * See the documentation on testing with gRPC-java;</li>\n"
478-
" * <li> replace {@code $service_name$BlockingClient}"
479-
" with {@link $service_name$BlockingStub};</li>\n"
480-
" * <li> replace {@code $service_name$FutureClient}"
481-
" with {@link $service_name$FutureStub}.</li>\n"
482-
" * </ul>\n"
483-
" */\n");
484-
}
485-
486455
// Prints a client interface or implementation class, or a server interface.
487456
static void PrintStub(
488457
const ServiceDescriptor* service,
489458
std::map<string, string>* vars,
490-
Printer* p, StubType type, bool generate_nano,
491-
bool enable_deprecated) {
459+
Printer* p, StubType type, bool generate_nano) {
492460
const string service_name = service->name();
493461
(*vars)["service_name"] = service_name;
494462
(*vars)["abstract_name"] = service_name + "ImplBase";
@@ -537,34 +505,13 @@ static void PrintStub(
537505
GrpcWriteServiceDocComment(p, service);
538506
}
539507
if (impl_base) {
540-
if (enable_deprecated) {
541-
p->Print(
542-
*vars,
543-
"public static abstract class $abstract_name$ implements $BindableService$, "
544-
"$service_name$ {\n");
545-
}
546-
else {
547-
p->Print(
548-
*vars,
549-
"public static abstract class $abstract_name$ implements $BindableService$ {\n");
550-
}
508+
p->Print(
509+
*vars,
510+
"public static abstract class $abstract_name$ implements $BindableService$ {\n");
551511
} else {
552-
if (enable_deprecated) {
553-
if (interface) {
554-
p->Print(
555-
*vars,
556-
"@$Deprecated$ public static interface $client_name$ {\n");
557-
} else {
558-
p->Print(
559-
*vars,
560-
"public static class $stub_name$ extends $AbstractStub$<$stub_name$>\n"
561-
" implements $client_name$ {\n");
562-
}
563-
} else {
564-
p->Print(
565-
*vars,
566-
"public static final class $stub_name$ extends $AbstractStub$<$stub_name$> {\n");
567-
}
512+
p->Print(
513+
*vars,
514+
"public static final class $stub_name$ extends $AbstractStub$<$stub_name$> {\n");
568515
}
569516
p->Indent();
570517

@@ -625,11 +572,6 @@ static void PrintStub(
625572
// TODO(nmittler): Replace with WriteMethodDocComment once included by the protobuf distro.
626573
if (!interface) {
627574
GrpcWriteMethodDocComment(p, method);
628-
if (enable_deprecated) {
629-
p->Print(
630-
*vars,
631-
"@$Override$\n");
632-
}
633575
}
634576
p->Print("public ");
635577
switch (call_type) {
@@ -784,8 +726,7 @@ static bool CompareMethodClientStreaming(const MethodDescriptor* method1,
784726
static void PrintMethodHandlerClass(const ServiceDescriptor* service,
785727
std::map<string, string>* vars,
786728
Printer* p,
787-
bool generate_nano,
788-
bool enable_deprecated) {
729+
bool generate_nano) {
789730
// Sort method ids based on client_streaming() so switch tables are compact.
790731
std::vector<const MethodDescriptor*> sorted_methods(service->method_count());
791732
for (int i = 0; i < service->method_count(); ++i) {
@@ -802,11 +743,7 @@ static void PrintMethodHandlerClass(const ServiceDescriptor* service,
802743
"private static final int $method_id_name$ = $method_id$;\n");
803744
}
804745
p->Print("\n");
805-
if (enable_deprecated) {
806-
(*vars)["service_name"] = service->name();
807-
} else {
808-
(*vars)["service_name"] = service->name() + "ImplBase";
809-
}
746+
(*vars)["service_name"] = service->name() + "ImplBase";
810747
p->Print(
811748
*vars,
812749
"private static final class MethodHandlers<Req, Resp> implements\n"
@@ -1059,7 +996,6 @@ static void PrintService(const ServiceDescriptor* service,
1059996
std::map<string, string>* vars,
1060997
Printer* p,
1061998
ProtoFlavor flavor,
1062-
bool enable_deprecated,
1063999
bool disable_version) {
10641000
(*vars)["service_name"] = service->name();
10651001
(*vars)["file_name"] = service->file()->name();
@@ -1131,38 +1067,12 @@ static void PrintService(const ServiceDescriptor* service,
11311067
p->Print("}\n\n");
11321068

11331069
bool generate_nano = flavor == ProtoFlavor::NANO;
1134-
PrintStub(service, vars, p, ABSTRACT_CLASS, generate_nano, enable_deprecated);
1135-
PrintStub(service, vars, p, ASYNC_CLIENT_IMPL, generate_nano, enable_deprecated);
1136-
PrintStub(service, vars, p, BLOCKING_CLIENT_IMPL, generate_nano, enable_deprecated);
1137-
PrintStub(service, vars, p, FUTURE_CLIENT_IMPL, generate_nano, enable_deprecated);
1138-
1139-
if (enable_deprecated) {
1140-
PrintDeprecatedDocComment(service, vars, p);
1141-
PrintStub(service, vars, p, ASYNC_INTERFACE, generate_nano, true);
1142-
PrintDeprecatedDocComment(service, vars, p);
1143-
PrintStub(service, vars, p, BLOCKING_CLIENT_INTERFACE, generate_nano, true);
1144-
PrintDeprecatedDocComment(service, vars, p);
1145-
PrintStub(service, vars, p, FUTURE_CLIENT_INTERFACE, generate_nano, true);
1146-
1147-
PrintDeprecatedDocComment(service, vars, p);
1148-
p->Print(
1149-
*vars,
1150-
"@$Deprecated$ public static abstract class Abstract$service_name$"
1151-
" extends $service_name$ImplBase {}\n\n");
1070+
PrintStub(service, vars, p, ABSTRACT_CLASS, generate_nano);
1071+
PrintStub(service, vars, p, ASYNC_CLIENT_IMPL, generate_nano);
1072+
PrintStub(service, vars, p, BLOCKING_CLIENT_IMPL, generate_nano);
1073+
PrintStub(service, vars, p, FUTURE_CLIENT_IMPL, generate_nano);
11521074

1153-
// static bindService method
1154-
PrintDeprecatedDocComment(service, vars, p);
1155-
p->Print(
1156-
*vars,
1157-
"@$Deprecated$ public static $ServerServiceDefinition$ bindService("
1158-
"final $service_name$ serviceImpl) {\n");
1159-
(*vars)["instance"] = "serviceImpl";
1160-
PrintBindServiceMethodBody(service, vars, p, generate_nano);
1161-
p->Print(
1162-
*vars,
1163-
"}\n\n");
1164-
}
1165-
PrintMethodHandlerClass(service, vars, p, generate_nano, enable_deprecated);
1075+
PrintMethodHandlerClass(service, vars, p, generate_nano);
11661076
PrintGetServiceDescriptorMethod(service, vars, p, flavor);
11671077
p->Outdent();
11681078
p->Print("}\n");
@@ -1206,14 +1116,12 @@ void PrintImports(Printer* p, bool generate_nano) {
12061116
void GenerateService(const ServiceDescriptor* service,
12071117
google::protobuf::io::ZeroCopyOutputStream* out,
12081118
ProtoFlavor flavor,
1209-
bool enable_deprecated,
12101119
bool disable_version) {
12111120
// All non-generated classes must be referred by fully qualified names to
12121121
// avoid collision with generated classes.
12131122
std::map<string, string> vars;
12141123
vars["String"] = "java.lang.String";
12151124
vars["Override"] = "java.lang.Override";
1216-
vars["Deprecated"] = "java.lang.Deprecated";
12171125
vars["Channel"] = "io.grpc.Channel";
12181126
vars["CallOptions"] = "io.grpc.CallOptions";
12191127
vars["MethodType"] = "io.grpc.MethodDescriptor.MethodType";
@@ -1255,7 +1163,7 @@ void GenerateService(const ServiceDescriptor* service,
12551163
if (!vars["Package"].empty()) {
12561164
vars["Package"].append(".");
12571165
}
1258-
PrintService(service, &vars, &printer, flavor, enable_deprecated, disable_version);
1166+
PrintService(service, &vars, &printer, flavor, disable_version);
12591167
}
12601168

12611169
string ServiceJavaPackage(const FileDescriptor* file, bool nano) {

compiler/src/java_plugin/cpp/java_generator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ string ServiceClassName(const google::protobuf::ServiceDescriptor* service);
5050
void GenerateService(const google::protobuf::ServiceDescriptor* service,
5151
google::protobuf::io::ZeroCopyOutputStream* out,
5252
ProtoFlavor flavor,
53-
bool enable_deprecated,
5453
bool disable_version);
5554

5655
} // namespace java_grpc_generator

compiler/src/java_plugin/cpp/java_plugin.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ class JavaGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
3737
java_grpc_generator::ProtoFlavor flavor =
3838
java_grpc_generator::ProtoFlavor::NORMAL;
3939

40-
bool enable_deprecated = false;
4140
bool disable_version = false;
4241
for (size_t i = 0; i < options.size(); i++) {
4342
if (options[i].first == "nano") {
4443
flavor = java_grpc_generator::ProtoFlavor::NANO;
4544
} else if (options[i].first == "lite") {
4645
flavor = java_grpc_generator::ProtoFlavor::LITE;
47-
} else if (options[i].first == "enable_deprecated") {
48-
enable_deprecated = options[i].second == "true";
4946
} else if (options[i].first == "noversion") {
5047
disable_version = true;
5148
}
@@ -61,7 +58,7 @@ class JavaGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
6158
std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output(
6259
context->Open(filename));
6360
java_grpc_generator::GenerateService(
64-
service, output.get(), flavor, enable_deprecated, disable_version);
61+
service, output.get(), flavor, disable_version);
6562
}
6663
return true;
6764
}

examples/build.gradle

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ protobuf {
4646
}
4747
generateProtoTasks {
4848
all()*.plugins {
49-
grpc {
50-
// To generate deprecated interfaces and static bindService method,
51-
// turn the enable_deprecated option to true below:
52-
option 'enable_deprecated=false'
53-
}
49+
grpc {}
5450
}
5551
}
5652
}

0 commit comments

Comments
 (0)