# java wrapper vtkWrapJava-xxx.exe issue

**URL:** https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428
**Category:** Development
**Created:** [October 5, 2023, 5:23pm UTC](https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428 "2023-10-05T17:23:26Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Julien](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@Julien](https://discourse.vtk.org/u/Julien)
#### Post date: [October 5, 2023, 5:23pm UTC](https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428/1 "2023-10-05T17:23:27Z")

</div>

Hello Everyone,

I am using VTK via the Java binding and I ran into a few oddities about the Java API.

For instance, I am trying to use a `vtkHigherOrderCurve`, and was expecting to access the ParametricCoords in Java.

The fact is, I could see only a « SetParametricCoords() » function in the Java generated class, not a getter — like a hypothetical GetParametricCoords() function.

Here is the public API from the `vtkHigherOrderCurve` from the Java class:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/1/1915689bd1c2ac42ee5a249c647e437da2d0a0d2.png)

So, I had a look at the API documentation and could find that the `GetParametricCoods` actually exists (which is fortunate 😄 )  
[https://vtk.org/doc/nightly/html/classvtkHigherOrderCurve.html#a80d58cb1f91458e28411eea45533fb94](https://vtk.org/doc/nightly/html/classvtkHigherOrderCurve.html#a80d58cb1f91458e28411eea45533fb94)

 ![image](https://discourse.vtk.org/uploads/default/original/2X/f/f33a42966539cc3fd8291654db90d247df6434c4.png)

It’s also clearly declared in the sources I compiled (and it’s also defined in the .cxx, obviously):

 ![image](https://discourse.vtk.org/uploads/default/original/2X/e/e102593a6e7672d342620ece49e3783a84a8b88c.png)

So, I kept searching about the \*.java wrapping source automatic generation and finally understood it’s done with an intermediate C program named `vtkWrapJava-xxx.exe`, which compiled at first and then called at the right time thanks to the `vtkCommonDataModelJava-java-sources` project and `vtkHigherOrderCurve.java`.rule (pretty neat contraption by the way!).  
A similar mechanism is used to generate the C++ intermediate JNI dynamic library source code (DLL in my case) with the `vtkCommonDataModelJava` project and `vtkHigherOrderCurveJava.cxx.rule`.

![image](https://discourse.vtk.org/uploads/default/original/2X/c/c4b2eb4fd24e55147ce6b1cb1a3f5b0edc98e737.png)

… 1/2 …

---

<div class="post-metadata">

### Author: ![Julien](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@Julien](https://discourse.vtk.org/u/Julien)
#### Post date: [October 5, 2023, 5:24pm UTC](https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428/2 "2023-10-05T17:24:10Z")

</div>

… 2/2 …

Now, for some reason, the `vtkWrapJava-xxx.exe` program outputs the `SetParametricCoords()` function in the Java file but it won’t write the `GetParametricCoords()` function?! (and maybe some others functions are missing as well, I haven’t checked it yet)  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/f/fa27829d124c327b22b540dfd81a0ec3a07cf399.png)

Now, I can’t fathom a genuine reason for the `GetParametricCoords()` for being skipped.  
My understanding is that there might be a bug or limitation in the `vtkWrapJava-xxx.exe` program, and so I am about to trace its execution with the Visual Studio debugger to see what it really does when it comes to this `GetParametricCoords` function of the `vtkHigherOrderCurve.h`.

I would expect it to write something similar to this in the `.java/.cxx` it generates (I wrote the getter myself as an example) :

 ![image](https://discourse.vtk.org/uploads/default/original/2X/8/85ff824de173a57edcc73c9e5ab475765686f789.png)

Now that I wrote it manually, I wonder if maybe it’s because it could not know the « `double*` » array size to allocate with `newDoubleArray` and so it skips it?

As I said, I am going to check what `vtkWrapJava-xxx.exe` actually does, but any help or explanation on this issue would be quite nice from someone who knows something about the whole process!

If I really have to add some JNI functions to the \*.cxx and `*.java` I guess I will have to do it anyway, but I really would prefer I didn’t have to, and obviously I would need to do it in way so that it’s not overwritten at the next compilation ^^

Thanks in advance for any tips!

PS: sorry about the first post split, I had to do it because I am a newbie here and cannot post more than 4 media in a single post apparently.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [October 5, 2023, 5:44pm UTC](https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428/3 "2023-10-05T17:44:09Z")

</div>

> [@Julien](#):
>
> Now that I wrote it manually, I wonder if maybe it’s because it could not know the « `double*` » array size to allocate with `newDoubleArray` and so it skips it?

That’s exactly it.

Cc: @dgobbi

---

<div class="post-metadata">

### Author: ![Julien](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@Julien](https://discourse.vtk.org/u/Julien)
#### Post date: [October 5, 2023, 10:29pm UTC](https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428/4 "2023-10-05T22:29:09Z")

</div>

Well … shucks! That’s unfortunate! Technically understandable of course, but unfortunate nonetheless!  
Thank you very much for the infos! How are the java guys doing to use vtk? Do they stick by the implemented functionalities?

Do you have an idea of the ratio of the problematic functions versus the correct ones? I could add some log to `vtkWrapJava-xxx.exe` to compute this. I hope I won’t need too many of them …!

If there is a lot to write initially, couldn’t it be a community job to manually write the new functions? Then it would be simple to add the new ones along when they are added to the vtk core? (with some kind of diff/patch added to the generated sources?) I don’t know if there is an active community big enough to do this?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [October 6, 2023, 1:59am UTC](https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428/5 "2023-10-06T01:59:52Z")

</div>

I suspect that this method is even missed in Python as it also needs to know how much to put into the returned `list` object. If it is dynamic, we’ll need some other way to communicate the size of this array.

> [@Julien](#):
>
> Do you have an idea of the ratio of the problematic functions versus the correct ones? I could add some log to `vtkWrapJava-xxx.exe` to compute this. I hope I won’t need too many of them …!

A `-Wunwrapped` warning to the wrappers probably wouldn’t be the worst thing in the world. I don’t think we can enable it by default though.

Other Java users (or those who have at least asked questions about it): @toddy @Sebastien_Jourdain

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [October 6, 2023, 5:21am UTC](https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428/6 "2023-10-06T05:21:53Z")

</div>

In **vtkCell**

`virtual double* GetParametricCoords() VTK_SIZEHINT(3 * GetNumberOfPoints());`

It contains a size hint so it should work but I see it is a virtual function and the overrides are all missing that size information. Possibly a bug in the wrapper logic on the descendant methods.

Did I mention that I think public virtual methods are bad idea?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 7, 2023, 2:52am UTC](https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428/7 "2023-10-07T02:52:46Z")

</div>

`double* GetParametricCoords() VTK_SIZEHINT(3*GetNumberOfPoints());`

This method actually is available in Python, because the Python wrappers are able to utilize hints that involve function calls, like the `GetNumberOfPoints()` call here.

The Java wrappers lack this level of sophistication. They can only utilize size hints that are constants.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [October 7, 2023, 2:58am UTC](https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428/8 "2023-10-07T02:58:37Z")

</div>

I imagine that cuts out quite a few methods in the Java wrapper code then.

---

<div class="post-metadata">

### Author: ![Julien](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@Julien](https://discourse.vtk.org/u/Julien)
#### Post date: [October 11, 2023, 11:26am UTC](https://discourse.vtk.org/t/java-wrapper-vtkwrapjava-xxx-exe-issue/12428/9 "2023-10-11T11:26:09Z")

</div>

I am going to get back on this subject soon guys.  
Thank you very much for your help already!
