Use top-level super method to determine annotation for @Internal apis#14
Conversation
| // When this is set to true, method calls will look for an annotation on the top-level method | ||
| // declaration. This is used to avoid io.grpc.internal implementations "hiding" publicly declared | ||
| // API methods. | ||
| protected boolean checkTopOfMethodHierarchy = false; |
There was a problem hiding this comment.
Why is this variable not final?
There was a problem hiding this comment.
I think it could be private final because it could be injected via constructor.
IMO, I want to add some tests if it could be, but it will make codes be weird. The package name is available via Compilation Unit Tree. Compilation Unit Tree is usually a root of Java AST so It could find via several ways.
If you(and me) want to add the checker to grpc-java examples, we could extend and override a method (verify the package name) only in tests... All of the ways I came up... |
|
If you want to leave the test alone, I will approve. I've checked this changes by grpc-java examples as well. |
|
Thanks for looking at this @jyane. @ejona86 is out until Monday, and I want to wait to get his feedback on the semantics of Re: the tests - ideally we would be able to include source code in the tests that does not get validated by the checker. This way, in the test set up, we can define some "gRPC library code" that does reference If that's not easily achievable with the existing test infrastructure, an alternate approach could be to combine your suggestion (override part of the checker in the tests) with a test-only "@IgnoreForTest" annotation that we could add to the tested source code where necessary. I'm more or less comfortable merging this without unit tests (pending @ejona86's feedback) since we've verified it manually; but getting test coverage should definitely at least be a follow-up item. |
|
@ericgribkoff and I spoke offline. I think simply "a non- |
|
@ejona86 Thanks! |
Intended to address #13
I couldn't find a good way to include coverage for this in the unit tests, as the current test setup doesn't allow defining a class that extends any
@Internalclasses, as is done in the gRPC library withManagedChannelBuilder->AbstractManagedChannelBuilder->NettyChannelBuilder. But I tested this manually with the gRPC examples code, and also verified that this works if the top-level declaration comes from a public interface rather than an abstract class.