Skip to content

Commit f8700a1

Browse files
authored
compiler: Default to @generated=omit (#12080)
After many years of issue 9179 being open, there's been nothing to show that we need the javax.annotations.Generated annotation. Most tools use file paths and a few check for annotations with "Generated" in the name. ErrorProne has a few that check for javax.annotations.Generated, but only UnnecessarilyFullyQualified looks like it'd be a problem and it is disabled by default. We're not getting any more information, no users have reported issues with `@generated=omit`, and the existing dependency is annoying users, so just drop it. Given we will still retain the GrpcGenerated annotation, it seems highly likely things are already okay. Even if there are problems they would probably be addressed by adding a io.grpc.stub.annotations.Generated annotation or small tweaks. In the short-term, (non-Bazel) users can use `@generated=javax`, but long-term we could consider removing the option assuming we've resolved any outstanding issues. We will want to update the examples and the README to remove the org.apache.tomcat:annotations-api dependency after the next release. Fixes #9179
1 parent 2fb0957 commit f8700a1

File tree

49 files changed

+6
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6
-145
lines changed

BUILD.bazel

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ java_library(
3333
"//api",
3434
"//protobuf",
3535
"//stub",
36-
"//stub:javax_annotation",
3736
"@com_google_protobuf//:protobuf_java",
3837
artifact("com.google.code.findbugs:jsr305"),
3938
artifact("com.google.guava:guava"),
@@ -47,7 +46,6 @@ java_library(
4746
"//api",
4847
"//protobuf-lite",
4948
"//stub",
50-
"//stub:javax_annotation",
5149
artifact("com.google.code.findbugs:jsr305"),
5250
artifact("com.google.guava:guava"),
5351
],
@@ -67,6 +65,5 @@ java_library(
6765
visibility = ["//:__subpackages__"],
6866
exports = [
6967
artifact("com.google.auto.value:auto-value-annotations"),
70-
artifact("org.apache.tomcat:annotations-api"), # @Generated for Java 9+
7168
],
7269
)

MODULE.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
4141
"io.opencensus:opencensus-contrib-grpc-metrics:0.31.0",
4242
"io.perfmark:perfmark-api:0.27.0",
4343
"junit:junit:4.13.2",
44-
"org.apache.tomcat:annotations-api:6.0.53",
4544
"org.checkerframework:checker-qual:3.12.0",
4645
"org.codehaus.mojo:animal-sniffer-annotations:1.24",
4746
]

alts/src/generated/main/grpc/io/grpc/alts/internal/HandshakerServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/gcp/handshaker.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class HandshakerServiceGrpc {
129

android-interop-testing/src/generated/debug/grpc/io/grpc/testing/integration/LoadBalancerStatsServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service used to obtain stats for verifying LB behavior.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class LoadBalancerStatsServiceGrpc {
1512

android-interop-testing/src/generated/debug/grpc/io/grpc/testing/integration/MetricsServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/testing/metrics.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class MetricsServiceGrpc {
129

android-interop-testing/src/generated/debug/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service used to control reconnect server.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class ReconnectServiceGrpc {
1512

android-interop-testing/src/generated/debug/grpc/io/grpc/testing/integration/TestServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
* performance with various types of payload.
99
* </pre>
1010
*/
11-
@javax.annotation.Generated(
12-
value = "by gRPC proto compiler",
13-
comments = "Source: grpc/testing/test.proto")
1411
@io.grpc.stub.annotations.GrpcGenerated
1512
public final class TestServiceGrpc {
1613

android-interop-testing/src/generated/debug/grpc/io/grpc/testing/integration/UnimplementedServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
* that case.
99
* </pre>
1010
*/
11-
@javax.annotation.Generated(
12-
value = "by gRPC proto compiler",
13-
comments = "Source: grpc/testing/test.proto")
1411
@io.grpc.stub.annotations.GrpcGenerated
1512
public final class UnimplementedServiceGrpc {
1613

android-interop-testing/src/generated/debug/grpc/io/grpc/testing/integration/XdsUpdateClientConfigureServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service to dynamically update the configuration of an xDS test client.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class XdsUpdateClientConfigureServiceGrpc {
1512

android-interop-testing/src/generated/debug/grpc/io/grpc/testing/integration/XdsUpdateHealthServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service to remotely control health status of an xDS test server.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class XdsUpdateHealthServiceGrpc {
1512

android-interop-testing/src/generated/release/grpc/io/grpc/testing/integration/LoadBalancerStatsServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service used to obtain stats for verifying LB behavior.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class LoadBalancerStatsServiceGrpc {
1512

android-interop-testing/src/generated/release/grpc/io/grpc/testing/integration/MetricsServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/testing/metrics.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class MetricsServiceGrpc {
129

android-interop-testing/src/generated/release/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service used to control reconnect server.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class ReconnectServiceGrpc {
1512

android-interop-testing/src/generated/release/grpc/io/grpc/testing/integration/TestServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
* performance with various types of payload.
99
* </pre>
1010
*/
11-
@javax.annotation.Generated(
12-
value = "by gRPC proto compiler",
13-
comments = "Source: grpc/testing/test.proto")
1411
@io.grpc.stub.annotations.GrpcGenerated
1512
public final class TestServiceGrpc {
1613

android-interop-testing/src/generated/release/grpc/io/grpc/testing/integration/UnimplementedServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
* that case.
99
* </pre>
1010
*/
11-
@javax.annotation.Generated(
12-
value = "by gRPC proto compiler",
13-
comments = "Source: grpc/testing/test.proto")
1411
@io.grpc.stub.annotations.GrpcGenerated
1512
public final class UnimplementedServiceGrpc {
1613

android-interop-testing/src/generated/release/grpc/io/grpc/testing/integration/XdsUpdateClientConfigureServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service to dynamically update the configuration of an xDS test client.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class XdsUpdateClientConfigureServiceGrpc {
1512

android-interop-testing/src/generated/release/grpc/io/grpc/testing/integration/XdsUpdateHealthServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service to remotely control health status of an xDS test server.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class XdsUpdateHealthServiceGrpc {
1512

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/BenchmarkServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/testing/services.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class BenchmarkServiceGrpc {
129

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/ReportQpsScenarioServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/testing/services.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class ReportQpsScenarioServiceGrpc {
129

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/WorkerServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/testing/services.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class WorkerServiceGrpc {
129

compiler/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ java_library(
2222
"//api",
2323
"//protobuf",
2424
"//stub",
25-
"//stub:javax_annotation",
2625
artifact("com.google.code.findbugs:jsr305"),
2726
artifact("com.google.guava:guava"),
2827
"@com_google_protobuf//:protobuf_java",
@@ -35,7 +34,6 @@ java_library(
3534
"//api",
3635
"//protobuf-lite",
3736
"//stub",
38-
"//stub:javax_annotation",
3937
artifact("com.google.code.findbugs:jsr305"),
4038
artifact("com.google.guava:guava"),
4139
],

compiler/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,11 @@ protobuf {
184184
inputs.file javaPluginPath
185185
}
186186
ofSourceSet('test').configureEach {
187-
plugins { grpc {} }
187+
plugins {
188+
grpc {
189+
option '@generated=javax'
190+
}
191+
}
188192
}
189193
ofSourceSet('testLite').configureEach {
190194
builtins {
@@ -193,7 +197,6 @@ protobuf {
193197
plugins {
194198
grpc {
195199
option 'lite'
196-
option '@generated=omit'
197200
}
198201
}
199202
}

compiler/src/java_plugin/cpp/java_plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class JavaGrpcGenerator : public protobuf::compiler::CodeGenerator {
8080
java_grpc_generator::ProtoFlavor flavor =
8181
java_grpc_generator::ProtoFlavor::NORMAL;
8282
java_grpc_generator::GeneratedAnnotation generated_annotation =
83-
java_grpc_generator::GeneratedAnnotation::JAVAX;
83+
java_grpc_generator::GeneratedAnnotation::OMIT;
8484

8585
bool disable_version = false;
8686
for (size_t i = 0; i < options.size(); i++) {

grpclb/src/generated/main/grpc/io/grpc/lb/v1/LoadBalancerGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/lb/v1/load_balancer.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class LoadBalancerGrpc {
129

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/LoadBalancerStatsServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service used to obtain stats for verifying LB behavior.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class LoadBalancerStatsServiceGrpc {
1512

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/MetricsServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/testing/metrics.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class MetricsServiceGrpc {
129

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service used to control reconnect server.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class ReconnectServiceGrpc {
1512

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/TestServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
* performance with various types of payload.
99
* </pre>
1010
*/
11-
@javax.annotation.Generated(
12-
value = "by gRPC proto compiler",
13-
comments = "Source: grpc/testing/test.proto")
1411
@io.grpc.stub.annotations.GrpcGenerated
1512
public final class TestServiceGrpc {
1613

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/UnimplementedServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
* that case.
99
* </pre>
1010
*/
11-
@javax.annotation.Generated(
12-
value = "by gRPC proto compiler",
13-
comments = "Source: grpc/testing/test.proto")
1411
@io.grpc.stub.annotations.GrpcGenerated
1512
public final class UnimplementedServiceGrpc {
1613

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/XdsUpdateClientConfigureServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service to dynamically update the configuration of an xDS test client.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class XdsUpdateClientConfigureServiceGrpc {
1512

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/XdsUpdateHealthServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* A service to remotely control health status of an xDS test server.
88
* </pre>
99
*/
10-
@javax.annotation.Generated(
11-
value = "by gRPC proto compiler",
12-
comments = "Source: grpc/testing/test.proto")
1310
@io.grpc.stub.annotations.GrpcGenerated
1411
public final class XdsUpdateHealthServiceGrpc {
1512

istio-interop-testing/src/generated/main/grpc/io/istio/test/EchoTestServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: test/echo/proto/echo.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class EchoTestServiceGrpc {
129

repositories.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
4545
"io.opencensus:opencensus-contrib-grpc-metrics:0.31.0",
4646
"io.perfmark:perfmark-api:0.27.0",
4747
"junit:junit:4.13.2",
48-
"org.apache.tomcat:annotations-api:6.0.53",
4948
"org.checkerframework:checker-qual:3.12.0",
5049
"org.codehaus.mojo:animal-sniffer-annotations:1.24",
5150
]

rls/src/generated/main/grpc/io/grpc/lookup/v1/RouteLookupServiceGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/lookup/v1/rls.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class RouteLookupServiceGrpc {
129

services/src/generated/main/grpc/io/grpc/channelz/v1/ChannelzGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
* information.
99
* </pre>
1010
*/
11-
@javax.annotation.Generated(
12-
value = "by gRPC proto compiler",
13-
comments = "Source: grpc/channelz/v1/channelz.proto")
1411
@io.grpc.stub.annotations.GrpcGenerated
1512
public final class ChannelzGrpc {
1613

services/src/generated/main/grpc/io/grpc/health/v1/HealthGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/health/v1/health.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class HealthGrpc {
129

services/src/generated/main/grpc/io/grpc/reflection/v1/ServerReflectionGrpc.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
/**
66
*/
7-
@javax.annotation.Generated(
8-
value = "by gRPC proto compiler",
9-
comments = "Source: grpc/reflection/v1/reflection.proto")
107
@io.grpc.stub.annotations.GrpcGenerated
118
public final class ServerReflectionGrpc {
129

0 commit comments

Comments
 (0)