Open source Beta version of Java Dfinity Agent

Released beta version of open source Java Dfinity Agent. This library enables remotely connect Java application (or any JVM based solution) to Dfinity canister, invoke query or call methods and also asynchronously read state of call operation.
This agent is inspired by existing Rust Dfinity agent, using similar package structure and naming conventions.
To invoke query or call methods, developers can use either raw method or Builder classes, similar to Rust API. Additionally we also added support for Java Dynamic Proxy, which uses annotated Java interface to read canister and methods signatures.
Currently we support only methods with primitive types, complex types and objects support is in development, hopefully will be added soon.
The source of this library is published on Github and library is also published on Maven Central.
We also published a sample, demonstrating how to build Java Web Service application (HTTP REST GET and POST, Websockets) to call Dfinity query and call methods. You can find is sample here

Appreciate any feedback and suggestions.



Thank you for this contribution, we appreciate it very much and hope to see a lot of Java developers build on the IC. This contribution definitely makes it easier!

1 Like

Version 0.5.2 is out. Supports opt (Optional), vec (array) and principal Candid types. We added support for TypeMap, so I am going to work on remaining Candid types (record, variant). Currently I do not see too many use cases for service and function Candid types between Java and Motoko (or Rust) so this is something we ca implement later.



Incredible effort! :100:

Did you see the Candid test data in It would be great if all candid implementations would be tested agains that data, so make sure that interop works really well

Hi Joachim, yes that is a great suggestion. Currently is Candid type testing quite limited, I am using either internal serialize/deserialize and validating input against output and also using full loopback roundtrip against canister methods deployed on my local Dfinity instance. To isolate outputs for mock testing I captured real CBOR binary payloads from Dfinity HTTP response and stored them in the files
But like I said, the number of use cases is for now quite limited, definitely more work needs to be done there. Let me see how I can convert RUST Candid unit test procedure to JUnit. It might be interesting to have some generic procedure which can read test data for different use Candid types in some language neutral format (JSON?) so then it can be used for acceptance tests for different Candid language packages (Rust, Java, C, Go…) . Also maybe have one canister with Motoko or Rust test operations, which different language Agent versions use for acceptance as well.

The test suite I linked is not tied to rust, and is used by the Haskell library and the Motoko implementation as well. Sorry for the confusion that arises from having the Candid specification and test data in the same repo as one particular implementation.

Currently, you’d have to extend your candid parser with the few extra features needed to express the test files, and write your own test runner here. I am not sure how avoidable that is, given that languages differ quite a lot in how they integrate with Candid. But it shouldn’t be too much extra work, assuming you already have a Candid textual value parser.

Hi Joachim, yes, my mistake, I looked at Rust code before. You are right, test you shared are definitely much easier to convert to JUnit. Thanks for suggestions, I will start working on JUnit procedure using existing test data very soon.

1 Like

Version 0.5.3 is out. Added support for nat, nat8, nat16, nat32 and nat64. int and nat types are now deserialized to BigInteger. Rewrote type management to better support inner types. Fixed several exception handling and null support in Candid. Added 100+ Candid type test. Joachim, your test suite is extremely helpful, I was able to identify and fix several issues, especially related to exception handling and null values. I will keep adding additional test cases with future releases.

Here is also a short documentation, just some basic use cases. As we progress with our project we will add more detailed, professional documentations as well.

1 Like

It wasn’t just me, but thanks a lot for the praise :slight_smile: