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.

Replace javax.annotation.Generated with custom gRPC annotation

See original GitHub issue

Since Java 9 dropped javax.annotation.Generated users have had to explicitly depend on a dep (typically Tomcat’s annotation API) to get the annotation. It’d be nice not to need that the extra dep.

But even more important is that the removal of Generated from Java 9 upset the ecosystem as a whole and fragmented it so badly that I believe many tools are no longer assuming they can predict which annotation will be used and are heuristics like “is the annotation named ‘Generated’” to determine whether they should it as generated code.

If we do an investigation and find that indeed all the tools we may care about (linters, static analyzers, IDEs) are observing Generated annotations in any package, then we can make our own io.grpc.Generated. Unfortunately, I expect the io.grpc.GrpcGenerated annotation may not suffice because its name is not exactly “Generated.” We’ll also need to figure out what retention it needs.

Tools to investigate (off the top of my head): Error Prone, IntelliJ, Eclipse, Android linter, Find Bugs, Checkstyle. The tools to investigate should be those that may be used by gRPC users, not just those directly used by gRPC maintainers.

javax.annotation.processing.Generated is not a relevant replacement; see #3633. I highly doubt jakarta.annotation.Generated would ever be appropriate, even with it being the new home for the annotation; it’d only have an advantage if Nullable goes that way as well, which seems unlikely. But that’d also take investigation of Kotlin and other null-caring tools.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:8
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
mkjensencommented, Nov 9, 2022

FYI, I just tried upgrading a project from Spring Boot 2.7.4 to 3.0.0-M5.

One of the first issues I run into is:

[ERROR] <snip>/target/generated-sources/protobuf/grpc-java/<snip>ServiceGrpc.java:[12,17] error: cannot find symbol
[ERROR]   symbol:   class Generated
[ERROR]   location: package javax.annotation

Spring Boot 3 (Spring Framework 6) is moving to Jakarta EE 9 APIs (jakarta.) instead of EE 8 (javax.).

Depending on javax.annotation:javax.annotation-api:1.3.2 seems to be a workaround.

4reactions
gkwan-ibmcommented, Dec 1, 2022

IMO, using eclipse-transformer is a workaround. gRPC should support EE9/EE10 too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I use gRPC to generate java code '@javax ... - Stack Overflow
I use gRPC to generate code '@javax.
Read more >
Grpc maven plugin: annotate generated classes
Hi, I'm using the grpc maven plugin to generate java classes from proto files. I would like to annotate classes that are generated...
Read more >
Consuming a gRPC Service - Quarkus
Consuming gRPC services requires the gRPC classes to be generated. ... Don't forget to replace it with the name you used in the...
Read more >
Diff - platform/external/grpc-grpc-java - Google Git
-21,7 +21,7 @@ * </pre> */ @javax.annotation.Generated( - value = "by gRPC proto compiler (version 1.16.0-SNAPSHOT)", + value = "by gRPC proto compiler ......
Read more >
Trouble-Shooting | grpc-spring-boot-starter - GitHub Pages
Note: grpc-spring-boot-starter isn't strictly bound to a specific version of grpc-java, so you can also use this to change the version of grpc-java...
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