This project demonstrates a solution to the „gRPC Java is not usable from Java 9 modules“ issue reported on the grpc/grpc-java project.
The code from @mmichaelis' poc-grpc project has been repurposed for this demo.
The solution is an implementation of the Bridges to the class path approach discussed by Oracle's Java Platform Group's Lead Architect, Mark Reinhold in the OpenJDK project's State of the Module System document.
The basic idea behind this solution can be summed up by Reinhold's advice: „If, however, multiple JAR files on the class path intentionally contain types in the same package then on the class path they must remain“.
This demo project was built with JDK 14 and tested with JDK 11. However, the general approach is applicable to JDK 9+.
The following steps assume Maven 3.5+ and JDK 11+ are installed in your development environment.
- Download or clone this project to your machine
- In a terminal,
cd
to the root folder of the project - Run
mvn install
- Set an environment variable named
M2_REPO
that refers to your system's Maven repository- e.g.
export M2_REPO=/home/foo/.m2/repository
- e.g.
- Run the
start.server
script- e.g.
./start.server
(chmod ugo+rx
if neccessary)
- e.g.
- Open a second terminal and run the
start.client
script
If all the steps succeeded, you should see „Hello, Mr. Foo Bar!“ in the client terminal.
Please report any failures of any of the above steps in this project's Issues section. Any questions or suggestions are also welcomed there.