Cannot compile repo ex-java-bindings
- jaypeedaOP 1
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 compileHowever 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/MojoFailureExceptionCould you please advise?
Thanks and Regards,
Jean-Paul
- stefanobaghino-da 1
Java 14 introduced
java.lang.Records. Since unfortunately Java doesn’t have an import aliasing mechanism, in order to usecom.daml.ledger.javaapi.data.Recordyou need to use the fully qualified name. Thanks @cocreature for the original answer. - stefanobaghino-da 4
While we don’t officially support Java 14, it makes sense to not block our users from experimenting using that. Since
java.lang.Recordwill soon be out as part of Java 17 LTS (which should be released later this year) we renamed ourRecordtoDamlRecord. As soon as a release will be made with this change in (likely 1.15.0) It will still be possible to useRecordbut it will be marked as deprecated. The Java codegen will also switch to the new name. - jaypeeda 2
Thanks Stefano !