Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Types #68

Open
pavelrappo opened this issue Sep 12, 2018 · 1 comment
Open

Generic Types #68

pavelrappo opened this issue Sep 12, 2018 · 1 comment

Comments

@pavelrappo
Copy link

There's an example of a generic struct on Cap’n Proto page:

...
struct Map(Key, Value) {
  entries @0 :List(Entry);
  struct Entry {
    key @0 :Key;
    value @1 :Value;
  }
}
...

After compiling it, I cannot seem to find the corresponding

public static final Factory factory

field in the class Map. There are factories for other types mentioned in the example, but not for this one. Why is that? Does it have anything to do with generics in Java not being reifiable?

@dwrensha
Copy link
Member

The factory type depends on the generic parameters. You need to specify those parameters in order to construct a factory. The generated code for your Map struct should include a Map.newFactory() function that you can use for this purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants