arangodb-java-driver icon indicating copy to clipboard operation
arangodb-java-driver copied to clipboard

Remove --allow-incomplete-classpath from native-image.properties

Open ppalaga opened this issue 3 years ago • 4 comments

--allow-incomplete-classpath is suitable for debugging but nor for running production code. Its presence in arangodb-java-driver enables it for all projects depending on it. The maintainers of those projects thus may get mislead into believing that their code is correct (because otherwise the native compilation would have failed) but in reality the code is broken and may fail in production.

ppalaga avatar Jun 18 '21 17:06 ppalaga

This parameter has been added to avoid compilation failure when optional maven dependencies (httpclient and jackson-dataformat-velocypack) are not present. I think the impact of this flag on projects depending on it will be mitigated by https://github.com/oracle/graal/issues/3491#issuecomment-865352456

@ppalaga how would you suggest to fix it for the moment? I would like to avoid including all the optional dependencies...

rashtao avatar Jun 29 '21 10:06 rashtao

I do not know all the necessary details about arangodb-java-driver, but from what you say it sounds like moving the code requiring those deps to new artifacts (maven modules) could be a solution? In the core arangodb-java-driver you could perhaps define SPIs that would be implemented in those new ancillary modules (call them arangodb-java-driver-http and arangodb-java-driver-jackson-dataformat-velocypack). arangodb-java-driver-http and arangodb-java-driver-jackson-dataformat-velocypack would non-optionally depend on httpclient and jackson-dataformat-velocypack respectivelly. arangodb-java-driver would not have to depend on any of the ancillary modules. End users would have to depend on arangodb-java-driver-http and arangodb-java-driver-jackson-dataformat-velocypack in their apps instead of httpclient and jackson-dataformat-velocypack.

Depending on how much your API is soaked by httpclient and jackson-dataformat-velocypack, this might or might not be a backwards compatible change.

Does this proposal make any sense?

ppalaga avatar Jun 29 '21 13:06 ppalaga

I agree, thanks for sharing @ppalaga . We could implement SPIs for CommunicationProtocol and ConnectionFactory, and this would remove the need for optional maven dependencies and related native-image errors. Nonetheless this would result in breaking API changes, so we will implement this change in the next major release.

rashtao avatar Jun 30 '21 09:06 rashtao

We will implement this change in the next major release.

Thanks a lot, that sounds like a good plan to me!

ppalaga avatar Jun 30 '21 13:06 ppalaga

Fixed in https://github.com/arangodb/arangodb-java-driver/releases/tag/v7.0.0-ALPHA.1

rashtao avatar Jan 20 '23 10:01 rashtao

Since version 7.0.0 the driver can compile to native image with --link-at-build-time. Modules are discovered via SPI. Note that when using http-protocol additional substitutions might be needed, due to incomplete classpath in Netty transitive dependency, see https://github.com/arangodb/arangodb-java-driver/blob/v7/docs/v7_detailed_changes.md#graalvm-native-image

https://github.com/arangodb/arangodb-java-driver/releases/tag/v7.0.0-RC.4

rashtao avatar Mar 21 '23 14:03 rashtao

Closing as fixed in version 7.0.0. Related documentation can be found at (PR): https://github.com/arangodb/docs/blob/113c2351a0153171adfc74c313454af6bb5c7f08/drivers/java.md?plain=1#L62-L68

Please reopen in case of further problems or questions.

rashtao avatar Apr 20 '23 12:04 rashtao