Closed c-aug closed 3 years ago
Hm... that example seems to work for me.
Are you sure that you are using the latest version of the capnpc-java
plugin? How did you install it?
This is with the following setup in Maven:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>foo</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.capnproto</groupId>
<artifactId>runtime</artifactId>
<version>0.1.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.expretio.maven.plugins</groupId>
<artifactId>capnp-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Compiling is all done via mvn install
.
Ah, looks like you are using https://github.com/expretio/capnp-maven-plugin, which has not been kept up to date with recent releases. You could open an issue on that repo to request an update. (I'm not sure whether it's being actively maintained.) Meanwhile, you're probably going to need to install canpnc-java
more manually.
What I'd like to do eventually is rewrite capnpc-java in Java, to avoid this kind of distribution problem. I opened #111 to track that issue.
My guess is that capnp-maven-plugin does not include this fix: https://github.com/capnproto/capnproto-java/commit/7da1dc8159cecc8995c88e025394e22606406f1b
Thanks for this. I can confirm that the schema compiles correctly with the latest version of capnproto-java
; the problem was the old version in the plugin.
I am happy for you to close this issue if you want.
The following code doesn't compile in capnp java v0.1.9:
It gets errors like
The code compiles correctly in the C++ capnp. Note that the
Map
implementation is copied directly from https://capnproto.org/language.html#generic-types , so this should work.I think it's the nested generics causing trouble, e.g. this works:
Using
:Map(Text, Text)
, or movingEntry
to be a top level struct (i.e. moving it outside ofMap
) still fail.