-
Notifications
You must be signed in to change notification settings - Fork 46
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
[Java] Java Cookbook fails on 16.0.0-SNAPSHOT #347
Comments
I haven't seen this error. It could be related to JPMS. We also updated gRPC's few times, merged some flight modules into one module, and changed some of the shading in Flight (though that may have only affected clients and not the server). I'll take a peek at the cookbook and let you know how it goes @amoeba |
Thanks so much @jduo. |
@amoeba , I was able to make this work by making some changes to the POM. This seems like the wrong way to resolve the issue though -- we seem to have some problems getting transitive dependencies. In the demo pom.xml:
These are both from grpc-java.
@lidavidm , do you know if the flight-core artifact is supposed to be the shaded classifier by default? And any ideas why we might not be inheriting transitive dependencies anymore? |
I don't think shading is meant to be the default. I didn't even realize we shipped a separate shaded version. Regardless, can we just compare 15.0.0 and 16.0.0 and see what might have changed? |
In fact, apache/arrow@92682f0 seems to be the only commit in 16.0.0 touching flight-core. |
When using the unshaded flight-core artifact I add grpc dependencies explicitly:
and this leads to the following error:
I'm looking into this. However it's worth noting that using dependency:build-classpath doesn't separate out JARs that should go on the module-path (ie JPMS modules) vs. JARs that should go on the classpath. jshell requires you to explicitly put JARs that are to be used as JPMS modules on the module-path parameter. Everything put on the classpath goes into the unnamed module, which is why in the error above, FlightDescriptor is being shown as part of the unnamed module instead of the org.apache.flight.core module. This differs from running tests from maven, where maven inspects JAR metadata to figure out if they support JPMS or not. |
Hmm so are we just invoking JShell wrongly then? |
I was able to get past the above error by adding an explicit dependency on protobuf to the demo pom too:
It seems that unnamed modules cannot access other dependencies in the unnamed module that have been brought in transitively, but can when they have been brought in explicitly:
The right thing to do is likely to correctly build module-path and classpath separately when using Arrow 16+. I don't see a friendly way to do this compared to using the build-classpath target though. Maybe jshell isn't the way to go too and we should run via maven. We probably should step back and think about what we want to support. For example do we intend to allow for users to put Arrow in the unnamed module? If so, how do we make this friendlier -- alternate artifacts that skip adding module-info.java perhaps. |
I'd rather not try to support every possible permutation of ways to do things - unless there's a real need from other users then I'd vote that we try to fix what's happening here instead of adding yet another artifact upstream. |
I think we chose JShell here initially because it had less ceremony required (in particular not requiring nesting everything in a class/main method). If we have to move back to using "regular" classes then so be it. |
Since it sounds like there's not an easy way to tweak the current setup (using maven to pass the right info to jshell), it seems like refactoring the Java cookbook to use something like Does that seems like a good plan? I'm happy to take that on. |
Yeah that sounds like a good solution. It would work with both pre and post-JPMS builds. |
Today I started in on a rewrite of javadoctest.py that uses exec:java. I have the basic shell of it working so I think the approach will work. What I'm doing so far is basically:
I should have a PR up early next week. |
I put a PR up at #350 that refactors the Java cookbooks to use Maven instead of JShell. |
In #347 we found the way we have been running cookbooks for Java (JShell) doesn't work well with JPMS which was introduced in Arrow 16. This refactors `javadoctest.py` to run examples directly with Maven using `exec:java` instead of with JShell. This PR also bumps the Java source/target version to 11 to fix some compiler errors and fixes a few compilation errors in cookbook code. I ran into one snag will require a follow-up commit to this PR: The way the examples in [substrait.rst](https://raw.githubusercontent.com/apache/arrow-cookbook/main/java/source/substrait.rst) are written doesn't work with my approach. My approach splits each code snippet into its `import` statements and non-`import` statements, puts the imports outside the main class definition and puts the non-imports inside the class's main method. This works fine for every example except [substrait.rst](https://raw.githubusercontent.com/apache/arrow-cookbook/main/java/source/substrait.rst) which needs some of its code to be defined in the main class, e.g., We probably generally want to support examples that need this so I think we may need to rewrite all the Java cookbooks to have an explicit main class. @lidavidm suspected this might be the case in #347 (comment) but I do wonder if there is still a way to avoid this. Any ideas welcome. Fixes #347 Related #348
When I run
make javatest
from the latest main withARROW_NIGHTLY=1
, the Flight cookbook fails with,I'm not sure what might be causing this but I wonder if it's related to the recent JPMS changes. @jduo do you have any ideas? In case you're not familiar with how the Java cookbooks run, they essentially,
arrow-cookbook/java/ext/javadoctest.py
Lines 53 to 58 in 83aff2d
arrow-cookbook/java/ext/javadoctest.py
Line 80 in 83aff2d
TODOs from the thread below:
The text was updated successfully, but these errors were encountered: