-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gRPC Java is not usable from Java 9 modules #3522
Comments
The reason for the split is to keep the dependencies down for grpc-context.
A package per jar is my own preference, but that ship has sailed. How is Java 9 supposed to work with generated classes, that live in a parallel package hierarchy but different jars? |
cc @bogdandrutu as I remember some chatter about making context a top-level
type (not pinned to grpc). Any related issue on that note can link here for
another reason
|
@adriancole the issue isn't that it's in the io.grpc realm, its that the same package is split over multiple jars. Making grpc-context contain io.grpc.context.Context would solve this. |
@adriancole <https://github.com/adriancole> the issue isn't that it's in
the io.grpc realm, its that the same package is split over multiple jars.
Making grpc-context contain io.grpc.context.Context would solve this.
right, but what I meant (and didn't say) is that if we are breaking the
java package anyway, if there were a time to top-level the type, it would
be now
|
@carl-mastrangelo I can think of another option:
Now, the bigger question is whether something like Anyway, I've implemented a workaround that gets me unblocked for the time being by shading core, stub and context into a single JAR with a proper Java 9 module descriptor, but that's definitely not the right direction and I'm happy to help with both this issue and #3523 in any way I can (signed the CLA the other day, so we should be good to go from that perspective). |
This was discussed in #2847 |
Note: the generated code also can run afoul of Java 9 modules. If nothing else, the gRPC generated code is frequently in a separate JAR from the protobuf generated code, but the two exist in the same JAR. |
So now the problem still exists in Java 11. Anyone can provide a solution(even a temporary one)? |
@CasterKKK, the only workaround I know is to repackage the two JARs into a single one as outlined in #2727 (comment) |
Same problem for our projects. Are there any plans to support JPMS? |
Dead End because of grpc/grpc-java#3522
In order to work around grpc/grpc-java#3522 JPMS has been disabled within this project.
* gRPC classes * PB converters WIP * PB converters WIP * PB converters WIP * PB converters WIP * PB converters WIP * Hash fixes * Fixes * Fixes * Fixes * Fixes * Fixes * Fixes
Users have requested support for Java 11 in Apache Beam and since it uses grpc it would need for grpc libraries to be compatible with Java 11. Hopefully this request helps increase the priority for fixing this. |
Is there any progress or ETA for this issue maybe? |
We'll be looking into options this quarter. Main choices are to try to reduce dependencies of grpc-api and then combine grpc-context with grpc-api or to do a trick like com.google.guava:listenablefuture's empty version 9999.0. |
In the meantime, we have repackaged This module basically merges @ejona86 This is not to say that we are not looking forward to a proper Java 9+ module support in |
will this ever be fixed? |
Not sure if I'm missing something here, but isn't changing the major version the point of backwardly incompatible API changes?!
|
No, that's not true. They had to make their own because their spec said they had to if there was not a commonly agreed upon one for the language. And even without this issue, there are many competing contexts in Java. We cannot accept a v2 major version for this change. And if we did that would cascade downstream to all APIs that use it. If we introduced |
@ejona86 Although a breaking change is diametrically against keeping a major version number, if we can move from this impass with a package change in 1.x I think that will unblock a lot of developers. Any idea when this may happen? |
@ejona86 Any update on this, is this the best issue to follow? |
would still like support! |
Edit: Ignore me, I missed the bit about |
Following up on this a year later, is there any plans to actually make any required breaking changes to gRPC to fix this issue? I work for a large enterprise that has artifact on boarding requirements and gRPC sits at the core of our services. For many of these it is the lone dependencies that are not modularity compliant and we do not have the luxury of leveraging personal projects that hack around the issue. It sounds like we have run out of ideas and have spent multiple years trying to figure a way out of this problem that doesn't involve breaking changes somewhere. It ultimately sounds like a path just needs to be picked and go with it, understanding no matter what is done its going to break someone. IMO worrying about breaking people classpath's/dependency trees on upgrades should be the most minor of concerns. They are an absolute reality of Java and Maven dependency management. This already happens today across several grpc versions when guava is upgraded. The amount of times I've seen guava force multiple artifacts into a diamond dependency problem well surpasses the amount of gRPC projects that would be impacted by any modularity upgrades. I'm willing to do the work, just need an SME and reviewer of gRPC to pick a path. |
I’d be willing to help out as well, but only if the maintainers bless the effort and can ensure that there’s at least a chance of it being merged. I’d really like to solve this problem as well, as it is for myself (and I suspect a gigantic number of others) the final bit preventing us from moving to use Java modules. |
Checking in on this issue- is there any update on timeline for this? My organization is hoping to start using gRPC in our backend services, but our codebase is moving to Java 17 (and uses java modules), so it seems like this is not an option for us at this point. I was looking into the Are there any other workarounds that I could look into for gRPC to be an option for us? |
@AlexSolorio Helidon simply repackages existing You can still use all standard tooling to generate your Java classes from the |
@aseovic Thanks for the quick reply 😃. From what I can tell, it seems there might be a conflict between the grpc protobuf plugin ( Is there a Helidon version of |
Did not find a simple a suitable way to import gRPC to our current java projects (we have decided to use modern java and modular builds). |
@aperrot42 you can take a look at https://github.com/grpc/proposal/blob/master/P5-jdk-version-support.md specifically https://github.com/grpc/proposal/blob/master/P5-jdk-version-support.md#rationale . As part of dropping support for Java8 may be Java9 modules will be supported? |
@sanjaypujare, dropping old version support doesn't magically fix the issues here. We need to manually resolve the grpc-context vs grpc-api issue which is the biggest issue. Then we can work on smaller problems like Automatic-Module-Name which may still have some fallout, e.g., inprocess is in grpc-core and maybe should be split out. |
@ejona86 thanks. I was thinking that the work done to drop support for Java8 will also include adding support for Java9 modules. |
I have just been bitten by this issue. If shading gRPC doesn't work, we will be forced to fall back to a raw HTTP interface for our project. |
This is being addressed in #10313 . It merges grpc-context into grpc-api. grpc-context will then be empty and will depend on grpc-api, but will exclude the unnecessary dependencies from grpc-api if you are just using io.grpc.Context. So the main difference for grpc-context-only users is the jar file increases in size, but at least no extra dependencies. |
I'm happy this has finally been resolved. I'll test it next month. |
Please answer these questions before submitting your issue.
What version of gRPC are you using?
1.6.1
What JVM are you using (
java -version
)?What did you do?
Java 9 allows users to depend on older, non-modularized versions of the libraries by "converting" them to automatic modules. For example, when Maven dependencies on grpc are configured correctly, Java 9 allows me to do the following:
This allowed me to use classes from the
grpc-core
within my Java 9 module, but unfortunately it wouldn't compile:The issue is that Java 9 does not support split packages across modules and this is exactly what's happening here, as
io.grpc
package exists in bothgrpc-core
andgrpc-context
, and to make things worse bothgrpc-core
andgrpc-stub
have transitive dependency ongrpc-context
.I've tried excluding
grpc-context
from both modules using Maven exclusions, which allowed me to compile successfully, as I don't have any direct dependencies ongrpc-context
. However, I was not able to run the test server, because of the missingContext
class:There are several possible solutions, some better than the others:
grpc-context
intogrpc-core
and leave empty/dummygrpc-context
module around for backwards compatibility (although most people probably do not depend on it directly).grpc-context
module.io.grpc
package ingrpc-context
toio.grpc.context
, which would eliminate split package issue, but would break existing code that uses classes from the current location.In any case, I'm happy to help do the work, but someone will need to decide which approach to take.
The text was updated successfully, but these errors were encountered: