Cannot compile repo ex-java-bindings
Hi team,
I’m trying to play with Daml’s Java binding, and cloned the repo: https://github.com/digital-asset/ex-java-bindings
As mentioned in the readme, I tried to compile the solution using: mvn compile
However I am having below error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/jeanpaulsaysana/Projects/ex-java-bindings/src/main/java/examples/pingpong/reactive/PingPongProcessor.java:[107,21] reference to Record is ambiguous
both class com.daml.ledger.javaapi.data.Record in com.daml.ledger.javaapi.data and class java.lang.Record in java.lang match
[ERROR] /Users/jeanpaulsaysana/Projects/ex-java-bindings/src/main/java/examples/pingpong/reactive/PingPongReactiveMain.java:[96,25] reference to Record is ambiguous
both class com.daml.ledger.javaapi.data.Record in com.daml.ledger.javaapi.data and class java.lang.Record in java.lang match
[ERROR] /Users/jeanpaulsaysana/Projects/ex-java-bindings/src/main/java/examples/pingpong/reactive/PingPongReactiveMain.java:[98,33] reference to Record is ambiguous
both class com.daml.ledger.javaapi.data.Record in com.daml.ledger.javaapi.data and class java.lang.Record in java.lang match
[ERROR] /Users/jeanpaulsaysana/Projects/ex-java-bindings/src/main/java/examples/pingpong/reactive/PingPongReactiveMain.java:[99,33] reference to Record is ambiguous
both class com.daml.ledger.javaapi.data.Record in com.daml.ledger.javaapi.data and class java.lang.Record in java.lang match
[ERROR] /Users/jeanpaulsaysana/Projects/ex-java-bindings/src/main/java/examples/pingpong/reactive/PingPongReactiveMain.java:[100,33] reference to Record is ambiguous
both class com.daml.ledger.javaapi.data.Record in com.daml.ledger.javaapi.data and class java.lang.Record in java.lang match
[INFO] 5 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.909 s
[INFO] Finished at: 2021-06-28T15:10:18+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project example-ping-pong-java: Compilation failure: Compilation failure:
[ERROR] /Users/jeanpaulsaysana/Projects/ex-java-bindings/src/main/java/examples/pingpong/reactive/PingPongProcessor.java:[107,21] reference to Record is ambiguous
[ERROR] both class com.daml.ledger.javaapi.data.Record in com.daml.ledger.javaapi.data and class java.lang.Record in java.lang match
[ERROR] /Users/jeanpaulsaysana/Projects/ex-java-bindings/src/main/java/examples/pingpong/reactive/PingPongReactiveMain.java:[96,25] reference to Record is ambiguous
[ERROR] both class com.daml.ledger.javaapi.data.Record in com.daml.ledger.javaapi.data and class java.lang.Record in java.lang match
[ERROR] /Users/jeanpaulsaysana/Projects/ex-java-bindings/src/main/java/examples/pingpong/reactive/PingPongReactiveMain.java:[98,33] reference to Record is ambiguous
[ERROR] both class com.daml.ledger.javaapi.data.Record in com.daml.ledger.javaapi.data and class java.lang.Record in java.lang match
[ERROR] /Users/jeanpaulsaysana/Projects/ex-java-bindings/src/main/java/examples/pingpong/reactive/PingPongReactiveMain.java:[99,33] reference to Record is ambiguous
[ERROR] both class com.daml.ledger.javaapi.data.Record in com.daml.ledger.javaapi.data and class java.lang.Record in java.lang match
[ERROR] /Users/jeanpaulsaysana/Projects/ex-java-bindings/src/main/java/examples/pingpong/reactive/PingPongReactiveMain.java:[100,33] reference to Record is ambiguous
[ERROR] both class com.daml.ledger.javaapi.data.Record in com.daml.ledger.javaapi.data and class java.lang.Record in java.lang match
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Could you please advise?
Thanks and Regards,
Jean-Paul
Java 14 introduced java.lang.Records. Since unfortunately Java doesn’t have an import aliasing mechanism, in order to use com.daml.ledger.javaapi.data.Record you need to use the fully qualified name. Thanks @cocreature for the original answer.
While we don’t officially support Java 14, it makes sense to not block our users from experimenting using that. Since java.lang.Record will soon be out as part of Java 17 LTS (which should be released later this year) we renamed our Record to DamlRecord. As soon as a release will be made with this change in (likely 1.15.0) It will still be possible to use Record but it will be marked as deprecated. The Java codegen will also switch to the new name.
Thanks Stefano !