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

duplicate name "Index" between annotation class and library class #479

Closed
mythly opened this issue Nov 9, 2017 · 11 comments
Closed

duplicate name "Index" between annotation class and library class #479

mythly opened this issue Nov 9, 2017 · 11 comments
Labels

Comments

@mythly
Copy link

mythly commented Nov 9, 2017

I'm trying to create preset for faiss, which has a class named "Index".

The generated java code contains the following snippet

//...
@Name("std::vector<float>") public static class FloatVector extends Pointer {
    //...
    @Index public native float get(@Cast("size_t") long i);
    public native FloatVector put(@Cast("size_t") long i, float value);
     //...
}
//...
@Namespace("faiss") @NoOffset public static class Index extends Pointer {
    static { Loader.load(); }
    //...
}
//...

then the compiler complains

[ERROR] /home/motao/javacpp-presets/faiss/src/main/java/org/bytedeco/javacpp/faiss.java:[26,6] incompatible types: org.bytedeco.javacpp.faiss.Index cannot be converted to java.lang.annotation.Annotation

as org.bytedeco.javacpp.annotation.Index is shaded.

How should I fix it?

@saudet saudet added the question label Nov 9, 2017
@saudet
Copy link
Member

saudet commented Nov 9, 2017

Something like I've done for Chilitags can work around that:

infoMap.put(new Info().javaText("import org.bytedeco.javacpp.annotation.Index;"))

https://github.com/bytedeco/javacpp-presets/blob/master/chilitags/src/main/java/org/bytedeco/javacpp/presets/chilitags.java#L39

@saudet saudet closed this as completed Nov 9, 2017
@mythly
Copy link
Author

mythly commented Nov 9, 2017

I still get the same error after adding that Info.

The case is not that same, as there is no class named Index in https://github.com/bytedeco/javacpp-presets/blob/master/chilitags/src/main/java/org/bytedeco/javacpp/chilitags.java

@saudet
Copy link
Member

saudet commented Nov 9, 2017

There is one from OpenCV...

@saudet
Copy link
Member

saudet commented Nov 9, 2017

You could give the wrapping Java class a different name, if that's acceptable. That's usually what we should do anyway.

@mythly
Copy link
Author

mythly commented Nov 9, 2017

A different name is reasonable. I tried new Info("faiss::Index").javaNames("FaissIndex") but it made no differences. How could I change the name of the wrapping Java class?

The c++ class definition is here.

@saudet
Copy link
Member

saudet commented Nov 9, 2017 via email

@mythly
Copy link
Author

mythly commented Nov 9, 2017

Got it. Finally I see "BUILD SUCCESS".

Thanks very much for your help!

@tovbinm
Copy link

tovbinm commented Jul 5, 2019

@mythly @saudet where is that FAISS preset? I would like to have a look ;)

@ericxsun
Copy link

Got it. Finally I see "BUILD SUCCESS".

Thanks very much for your help!

where is that FAISS preset? I would like to have a look ;) @mythly

@saudet
Copy link
Member

saudet commented Jul 16, 2020

It's not available yet, see issue #827. Please consider making a contribution! Thanks

@mythly
Copy link
Author

mythly commented Jul 16, 2020

@tovbinm @ericxsun
Sorry, the preset is just a prove of concept and not finished.
Actually we decide to use handcraft C wrapper + JNI instead of javacpp in our project.
The reasons:

  1. we need only some specific interfaces of faiss and don't want to spend time wrapping the whole library
  2. we have some low level code which is much easier to be implemented in C rather than Java

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

No branches or pull requests

4 participants