Commit Graph

107 Commits

Author SHA1 Message Date
Benjamin Peterson 8c261c3f28
Fix typo in deprecated blocking stub javadoc. (#11772) 2024-12-26 13:31:34 -08:00
Larry Safran ea8c31c305
Bidi Blocking Stub (#10318) 2024-12-20 16:16:17 -08:00
Alex Panchenko 8a21afcc9e
compiler: add option `@generated=omit` (#11086)
related to #11081
2024-04-18 18:34:04 -07:00
David Ankin 0d39c2c701
implement ability to skip generation of javax annotation (#10927)
* commit to implement feedback from #10786 to partially fix #9179
2024-02-16 17:49:20 -08:00
Philip K. Warren 3808e707f9
compiler: Use fully qualified String in codegen (#10321)
Currently, the gRPC compiler isn't properly using the fully qualified
string name `java.lang.String` instead of `String`. Update the generator
to use the `$String$` alias to avoid compile issues with protobuf
messages called String.

Fixes #10316.
2023-06-29 10:50:13 -07:00
Eric Anderson cc28dfdb36 compiler: Inform the compiler that GRPC_CODEGEN_FAIL aborts
This is enough for the linter to realize that the missing break cases
do not imply fallthrough.
2023-02-27 10:01:07 -08:00
Terry Wilson d8c572dde6
compiler: add missing break in switch statement (#9901)
Linters don't like this kind of stuff.
2023-02-17 12:18:04 -08:00
Larry Safran 19eab29f8d
compiler: Generate interfaces for services to implement (#9688)
Introduce an AsyncService interface in the generated code and move the methods from <service>ImplBase to default implementation of the interface.
* update pom files to allow java 1.8
* Add a bindService(<service>Async) method
* Change TestServiceImpl to use the interface and include a bind method instead of extending TestServiceImplBase.
2023-02-15 10:33:44 -08:00
Eric Anderson 8154fadf7e compiler: Add docs describing requirements for generated code 2023-02-03 12:53:03 -08:00
Jeremy Volkman 84edc33239
Update to handle rename of java_names.h to names.h in protobuf upstream (#9218) 2022-05-31 15:08:10 -07:00
Eric Anderson 0cabf5672a compiler: Add GrpcGenerated annotation to generated class
This can be used by annotation processors to avoid processing the
gRPC-generated code. The normal Generated annotation only has SOURCE
retention, so isn't available to annotation processors.

I don't include the service name within the annotation as that assumes
we'll never have need for any other type of generated class. If there's
a request for exposing service name via an annotation in the future, we
can make an RpcService annotation or the like.

Fixes #8158
2021-07-02 22:11:40 -07:00
ZHANG Dapeng 7d77f64773
compiler: remove some of the static imports in codegen (#7751)
Resolves #7741 
Some of the static methods in generated code have the same method name but different package name, such `ClientCalls.asyncClientStreamingCall` and `ServerCalls.asyncClientStreamingCall`. It's less readable using static import than using full-qualified method name in-place.
2020-12-23 11:28:03 -08:00
Eric Anderson 19d690b435 compiler: Use namespace aliases to reduce internal diff
Due to historical reasons, protobuf is in the proto2:: namespace
internally instead of google::protobuf. We have been maintaining diffs
that replace each occurence of one with the other. Instead we can simply
create a namespace alias and use that alias instead of the canonical
name. That greatly reduces the size of the diff and its likelihood to
break.

If the names ever align in the future, we can swap back to the canonical
names.
2020-08-07 14:58:32 -05:00
Eric Anderson f59c9a9c6b compiler: Swap to ABSL_FALLTHROUGH_INTENDED
FALLTHROUGH_INTENDED was defined by Abseil, but is now getting an ABSL
prefix and the old name will be removed. Swapping to a new define name
to avoid redefining the existing-but-soon-to-be-deleted
FALLTHROUGH_INTENDED.
2020-08-06 11:24:12 -05:00
Andrew Gasparovic 2119fac35b
compiler: Remove unused function (#6911) 2020-04-08 14:12:00 -07:00
Jihun Cho 47c0b0b792
complier: fix typo in comment (#6747) 2020-02-24 14:32:26 -08:00
Jihun Cho 3b1af27073
compiler: add std:: qualifications to all references to std::string 2020-02-24 11:34:19 -08:00
Jihun Cho 7db873f1f6
Roll-forward of stub,compiler: generated stub extends Abstract{Async,Future,Blocking}Stub #6196 (#6458)
This reverts commit 2eb3f8c34e (#6317).
2019-11-25 09:41:16 -08:00
Jihun Cho 2eb3f8c34e
stub,compiler: Rollback Abstract{Future,Blocking,Async}Stub (#6317)
rollback of #6304 & #6196
2019-10-22 13:27:30 -07:00
Carl Mastrangelo f2d0f87d2e compiler: set safe and idempotent bits on method descriptors 2019-10-22 10:59:11 -07:00
Jihun Cho 45d49a56cc
stub,compiler: generated stub extends Abstract{Async,Future,Blocking}Stub (#6196) 2019-10-17 14:49:24 -07:00
Jihun Cho e3be6a6bfa
compiler: add license header for cpp codes (#6208) 2019-09-27 09:22:42 -07:00
liym 47b11ab7a1 compiler: Use 'SERVICE_NAME' instead of duplicated '$Package$$service… (#5943)
* compiler: Use 'SERVICE_NAME' instead of duplicated '$Package$$service_name$'

* compiler: Align indentation

* Fix typo

* Add modified golden files and all re-generated code to meet Travis CI and Windows build requirements

See PR #5943

* Polishing
2019-07-24 10:37:13 -07:00
Eric Anderson 50b08eee3b
Delete protobuf-nano
Nano was dropped from upstream protobuf. See gRFC L51
2019-05-22 08:49:07 -07:00
elandau 0d4051ca6e Include Java's @Deprecated annotation on RPC services or methods with `option deprecated = true;` 2018-08-15 12:24:01 -07:00
Carl Mastrangelo 146b6006b3
compiler,stub: update RpcMethod docs and usage 2018-07-12 17:01:47 -07:00
jbingham-google ffcb3b964b compiler, stub: Rename inputType and outputType in @RpcMethod 2018-07-10 13:24:50 -07:00
jbingham-google 9229e30287 compiler, stub: Add @RpcMethod annotation
This annotation will enable Java APT to generate code.

Addresses part of #3173.
2018-07-06 17:02:01 -07:00
Carl Mastrangelo 3934ad9f4b
compiler: add stubs for generating nano code as lite 2018-06-12 10:03:28 -07:00
Carl Mastrangelo 4c4fda3e5d
stub: remove static Method descriptors and stabilize method accessors 2018-06-05 11:19:28 -07:00
zpencer 8d3d26dda1
compiler: allow capitalized java keywords as rpc names (#4309)
previously `Import` fails because it gets turned into a method named
`import`. This PR makes the method be named `import_`, everything else
stays the same, such as the name in the method descriptor.

Note: `iMport` or `iMPORT` or any variation of capitalizations that is
not `Import` always worked. `Import` gets translated into `import`
because of our attempts to camel case the names.
2018-04-05 16:45:19 -07:00
Eric Gribkoff 6f9b4e87e1
compiler: avoid invoking experimental method in generated code 2018-02-08 11:25:38 -08:00
Kun Zhang d87ef74082
core: set sampled for local span per MethodDescriptor. (#3627)
This moves away from the global String-based Span name registry which
is not as flexible as we desire.

Also renamed the option name to be more accurate.  This is not
API-breaking because the origianl addition to MethodDescriptor and
code-gen didn't make it into the 1.7.0 release.
2017-11-01 16:46:05 -07:00
Carl Mastrangelo 87c8791983
compiler: remove references to static fields 2017-10-31 15:24:48 -07:00
Carl Mastrangelo 30b59885b7
compiler: add methods for accessing method descriptors
* MethodDescriptor is lazy loaded, so protobuf loading only happens on demand.  This also means tracing registration happens  on demand.
* The names of the getters all being with `method`.  This makes it harder for autocomplete to pick them up.
* A new field is used, which matches the getter name.  Rather than make the new-getters reference the old-fields, make the old-fields reference the new getters.  This makes removal of the old-fields a simple operation.
* The getters may not be inlineable, but thats an easy fix if it ends up being a problem.  Not worth premature optimization (but is worth future work).

The expected timeline for this is adding this to the 1.8 cut, and deprecating the old-fields.  They will be removed in 1.9.
2017-10-30 10:30:34 -07:00
ZHANG Dapeng dba2323585 compiler: Remove enable_depreated option (#3541) 2017-10-05 14:14:57 -07:00
Kun Zhang a6653bb135 core/compiler: register Span names for code-generated methods (take 2)
This is a more favorable approach than #3467. Doing the registration
in MethodDescriptor should allow us to deregister in case the
generated stub and its MethodDescriptors are garbage-collected
routinely, e.g., if they are loaded by a separate ClassLoader.
2017-09-25 15:38:48 -07:00
Lukasz Strzalkowski 731bbefb17 core, compiler, protobuf: introduce MethodDescriptor#setSchemaDescriptor 2017-09-11 09:57:03 -07:00
Eric Anderson 182164eafc compiler: Add option to disable version output
If the option becomes popular, we can just remove the version.
2017-08-23 12:37:40 -07:00
Eric Anderson de8b411773 compiler: Fix some warnings when building with Bazel
This fixes sign-compare and maybe-unintialized. An unused-value warning
remains.

I changed LogHelper to always call abort so the compiler would know the
method does not return, which fixed the maxbe-uninitialized warning.
2017-08-02 14:29:40 -07:00
Jakob Buchgraber 917f6faac6 compiler: Fix compilation error
The code uses std::back_insert_iterator which is part of the <iterator>
header. The header is not included though.

We (bazel) noticed the build failing on Windows when using the Visual Studio
C++ compiler.
2017-05-30 11:15:46 -07:00
Eric Gribkoff 7aa807ce6d compiler: remove streaming calls from javadoc for newFutureStub
FutureStubs only support unary calls
2017-05-02 10:24:23 -07:00
Łukasz Strzałkowski 4f96b0a483 compiler: move over to method descriptor builder 2017-04-12 08:56:46 -07:00
Carl Mastrangelo 700abb32af compiler: add some missing final modifiers on generated code 2017-02-10 10:16:43 -08:00
Carl Mastrangelo 237a65ebfc core: make ServiceDescriptor use the Builder pattern 2017-01-30 15:22:40 -08:00
Carl Mastrangelo cbe0ecd5e2 all: fix linter found on import 2017-01-27 15:47:53 -08:00
Carl Mastrangelo c4642f8b3d compile: add std:: to all stl types 2017-01-17 12:50:25 -08:00
ZHANG Dapeng 3d210ae875 compiler: reduce synchronzed invocation (#2539)
not necessary to synchronze every time calling
getServiceDescriptor(), if the descriptor has been created already;

go with the double-checked locking idom
2016-12-29 12:21:04 -08:00
Kun Zhang 1aaf1a989c compiler: final bindService() in generated code. (#2553)
So that it won't be overridden by Mockito when it creates a mock for
the server interface.
2016-12-29 10:32:47 -08:00
Eric Anderson 09fd43df4e compiler: Use public headers instead of pb.h
Using the pb.h causes trouble when dealing with internal vs external
protobuf (as seen in cl/142286800).
2016-12-29 12:13:54 -06:00