# \[Bugs\] Issue with compilation vtk to product a vtk.jar

**URL:** https://discourse.vtk.org/t/bugs-issue-with-compilation-vtk-to-product-a-vtk-jar/10392
**Category:** Development
**Created:** [January 5, 2023, 1:46pm UTC](https://discourse.vtk.org/t/bugs-issue-with-compilation-vtk-to-product-a-vtk-jar/10392 "2023-01-05T13:46:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![aschmit](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@aschmit](https://discourse.vtk.org/u/aschmit)
#### Post date: [January 5, 2023, 1:46pm UTC](https://discourse.vtk.org/t/bugs-issue-with-compilation-vtk-to-product-a-vtk-jar/10392/1 "2023-01-05T13:46:29Z")

</div>

Hello everyone,

I have tried to compile the source vtk to producta vtk.jar. But it fails because we have the enum arguments whose are truncated by the parser.

The possible origin of this behaviour is the function vtkParseHierarchy\_QualifiedName whose use a snprintf function.

```auto
        size_t scoped_len = strlen(data->Name) + strlen(info->Name) + 2;
        scoped_name = vtkParse_NewString(cache, scoped_len);
       snprintf(scoped_name, scoped_len, "%s::%s", data->Name, info->Name);

```

There, the length provided (scoped\_len) is too small and we have to increase of one. After a little correction, i have succeed to compile a vtk.jar

Could you let me know if it is the good thing to do?

Thank you so much and have a good day 🙂

Alexandre Schmit

---

<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: [January 5, 2023, 5:02pm UTC](https://discourse.vtk.org/t/bugs-issue-with-compilation-vtk-to-product-a-vtk-jar/10392/2 "2023-01-05T17:02:03Z")

</div>

Hi Alexandre, thanks for the report.

I’m a bit suspicious, though, because `vtkParse_NewString()` automatically adds 1, according to the documentation and in the code itself:

```c
  /**
   * Allocate a new string from the cache.
   * A total of n+1 bytes will be allocated, to leave room for null.
   */
  VTKWRAPPINGTOOLS_EXPORT
  char* vtkParse_NewString(StringCache* cache, size_t n);

```

Do you have any evidence that the name is truncated?

---

<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: [January 5, 2023, 6:10pm UTC](https://discourse.vtk.org/t/bugs-issue-with-compilation-vtk-to-product-a-vtk-jar/10392/3 "2023-01-05T18:10:50Z")

</div>

I might just be misunderstanding. Do you want this change?

```diff
- size_t scoped_len = strlen(data->Name) + strlen(info->Name) + 2;
+ size_t scoped_len = strlen(data->Name) + strlen(info->Name) + 3;

```

or do you want this change?

```diff
- snprintf(scoped_name, scoped_len, "%s::%s", data->Name, info->Name);
+ snprintf(scoped_name, scoped_len + 1, "%s::%s", data->Name, info->Name);

```

---

<div class="post-metadata">

### Author: ![aschmit](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/4491bb/32.png) [@aschmit](https://discourse.vtk.org/u/aschmit)
#### Post date: [January 5, 2023, 8:22pm UTC](https://discourse.vtk.org/t/bugs-issue-with-compilation-vtk-to-product-a-vtk-jar/10392/4 "2023-01-05T20:22:00Z")

</div>

Thank you for your answer,

I guess the better solution would be the first but the secund is good too.

I can have evidence if you want 🙂 but you can reproduce it in compiling the vtk with option VTK\_WRAP\_JAVA=ON

Have a nice evening
