question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add class-retention @GrpcGenerated annotation to generated types

See original GitHub issue

Is your feature request related to a problem?

Static analyzers (e.g. lint checks and proguard) would like to reliably detect that code has been generated by gRPC in order exclude it from some types of validation. Currently, gRPC-generated types are annotated with the @Generated annotation, but this only has SOURCE retention and is unavailable to these analyzers.

Describe the solution you’d like

Additionally add an @GrpcGenerated annotation with CLASS retention to generated types.

Describe alternatives you’ve considered

Currently we inspect generated code for anticipated naming schemes and structure (e.g. endsWith(“Grpc”) & contains X fields) in order to determine if it is grpc-generated. Obviously this is fragile and relies on implementation details that it shouldn’t.

Additional context

There is prior art for this kind of annotation in Dagger and AutoFactory (coming soon).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ejona86commented, May 11, 2021

I think @RpcService will be like @RpcMethod, nothing emphasizing generated code, or prohibiting non-generated usage.

@dapengzhang0, note that RpcMethod has this in its documentation:

This annotation is used by the gRPC stub compiler to annotate MethodDescriptor getters. Users should not annotate their own classes with this annotation.

0reactions
dapengzhang0commented, May 12, 2021

This annotation is used by the gRPC stub compiler to annotate MethodDescriptor getters. Users should not annotate their own classes with this annotation.

Then inspecting for @RpcMethod is less fragile than I thought.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GrpcGenerated (grpc-all 1.51.0 API)
Annotates that the class is gRPC-generated code to assist Java Annotation Processors. This annotation is used by the gRPC stub compiler to annotate...
Read more >
I use gRPC to generate java code '@javax.annotation ...
you can add javax.annotation-api dependencies to you maven pom.xml to resolve the annotation.
Read more >
Customizing gRPC Generated Code - ITNEXT
This code is generated by the protoc compiler from the .proto files. ... This will allow us to add helper/utility methods that have...
Read more >
Java Generated Code | Protocol Buffers - Google Developers
The protocol buffer compiler will generate a Java enum type called Foo with the same set of values. If you are using proto3,...
Read more >
Generated-code reference | Java - gRPC
gRPC Java generates code for three types of stubs: asynchronous, ... Typically the build system handles creation of the gRPC generated code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found