cleanup(generator): remove javax.annotation.Nonnull usage - #13960
Conversation
There was a problem hiding this comment.
Code Review
This pull request removes redundant @Nonnull annotations and their corresponding imports across several files, including TryCatchStatement.java, ImportWriterVisitor.java, SourceCodeInfoLocation.java, and TypeParser.java, as these classes are already annotated with @NullMarked. Feedback on the changes highlights that the body parameter in the addCatch method of TryCatchStatement.java is currently unused and suggests updating the builder to properly record the catch block statements.
|
|



This PR removes all occurrences of
javax.annotation.Nonnull(both imports and annotations) from the codebase ofgapic-generator-java.Why this change is needed:
As part of the migration to JSpecify annotations, generator classes are annotated with
@NullMarked, making all unannotated types non-nullable by default. The legacyjavax.annotation.Nonnullannotations are redundant and can be safely removed.Changes:
import javax.annotation.Nonnull;and@Nonnullfrom 4 files in the generator codebase (TypeParser.java,SourceCodeInfoLocation.java,TryCatchStatement.java, andImportWriterVisitor.java).fmt-maven-plugin.javax.annotation.Nonnullundergapic-generator-javahave been eliminated.