ochafik/nativelibs4java — Issue #205: BridJ (via JNAerator studio) fails to process simple code with includes throwing 'OutOfMemory'
Author: om-nom-nom
Created: 2011-11-27 13:27:42+00:00
State: open

Here is the snippet of header file:

```c
#include

void printSome(int argc, int xs[]);

int intTest(int arg);
```
Pretty simple, yeah, but BridJ has to parse out so after a while it fails. Here is the output of log:

```
/usr/include/c++/4.4.5/iostream:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/iosfwd:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/stringfwd.h:14:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cwchar:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cstddef:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cstddef:19:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/exception:11:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/stl_algobase.h:38:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/functexcept.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/cpp_type_traits.h:14:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/type_traits.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/move.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/concept_check.h:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/stl_iterator_base_types.h:42:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cstdio:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/stdio.h:28:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/_G_config.h:8:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/wchar.h:31:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/libio.h:35:0: error: File not found: stdarg.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/localefwd.h:14:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/localefwd.h:15:0: error: File not found: bits/c++locale.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cctype:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/atomicity.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/atomicity.h:13:0: error: File not found: bits/gthr.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/atomicity.h:14:0: error: File not found: bits/atomic_word.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/string:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/allocator.h:25:0: error: File not found: bits/c++allocator.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/streambuf:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cwctype:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/locale_facets.h:15:0: error: File not found: bits/ctype_base.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/locale_facets.h:1256:0: error: File not found: bits/ctype_inline.h in . /usr/include /usr/include/c++/4.4.5
Exception for /usr/include/c++/4.4.5/ios at line 1128:java.util.concurrent.ExecutionException: java.lang.Exception: java.lang.OutOfMemoryError: Java heap space
java.util.concurrent.ExecutionException: java.lang.Exception: java.lang.OutOfMemoryError: Java heap space
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:262)
at java.util.concurrent.FutureTask.get(FutureTask.java:119)
at com.ochafik.lang.jnaerator.JNAeratorParser.parseSlices(JNAeratorParser.java:177)
at com.ochafik.lang.jnaerator.JNAeratorParser.parse(JNAeratorParser.java:213)
at com.ochafik.lang.jnaerator.JNAerator.parseSources(JNAerator.java:1119)
at com.ochafik.lang.jnaerator.JNAerator.jnaerate(JNAerator.java:837)
at com.ochafik.lang.jnaerator.studio.JNAeratorStudio$14.run(JNAeratorStudio.java:607)
Caused by: java.lang.Exception: java.lang.OutOfMemoryError: Java heap space
at com.ochafik.lang.jnaerator.JNAeratorParser$1.call(JNAeratorParser.java:147)
at com.ochafik.lang.jnaerator.JNAeratorParser$1.call(JNAeratorParser.java:136)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.OutOfMemoryError: Java heap space
----------
1. WARNING in file:///test/_IO_marker.java (at line 17)
public _IO_marker(Pointer pointer) {
^^^^^^^
Pointer is a raw type. References to generic type Pointer should be parameterized
----------
2. WARNING in file:///test/_IO_marker.java (at line 18)
super(pointer);
^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer
----------
----------
3. WARNING in file:///test/_G_fpos64_t.java (at line 17)
public _G_fpos64_t(Pointer pointer) {
^^^^^^^
Pointer is a raw type. References to generic type Pointer should be parameterized
----------
4. WARNING in file:///test/_G_fpos64_t.java (at line 18)
super(pointer);
^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer
----------
----------
5. WARNING in file:///test/_G_fpos_t.java (at line 17)
public _G_fpos_t(Pointer pointer) {
^^^^^^^
Pointer is a raw type. References to generic type Pointer should be parameterized
----------
6. WARNING in file:///test/_G_fpos_t.java (at line 18)
super(pointer);
^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer
----------
----------
7. WARNING in file:///test/mbstate_t.java (at line 18)
public mbstate_t(Pointer pointer) {
^^^^^^^
Pointer is a raw type. References to generic type Pointer should be parameterized
----------
8. WARNING in file:///test/mbstate_t.java (at line 19)
super(pointer);
^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer
----------
----------
9. WARNING in file:///test/TestLibrary.java (at line 619)
return (Pointer<_IO_FILE >)BridJ.getNativeLibrary("test").getSymbolPointer("stdin").as(DefaultParameterizedType.paramType(Pointer.class, _IO_FILE.class)).get();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<_IO_FILE>
----------
10. WARNING in file:///test/TestLibrary.java (at line 650)
return (Pointer<_IO_FILE >)BridJ.getNativeLibrary("test").getSymbolPointer("stdout").as(DefaultParameterizedType.paramType(Pointer.class, _IO_FILE.class)).get();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<_IO_FILE>
----------
11. WARNING in file:///test/TestLibrary.java (at line 680)
return (Pointer<_IO_FILE >)BridJ.getNativeLibrary("test").getSymbolPointer("stderr").as(DefaultParameterizedType.paramType(Pointer.class, _IO_FILE.class)).get();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<_IO_FILE>
----------
12. WARNING in file:///test/TestLibrary.java (at line 728)
return (Pointer >)BridJ.getNativeLibrary("test").getSymbolPointer("sys_errlist").as(DefaultParameterizedType.paramType(Pointer.class, DefaultParameterizedType.paramType(Pointer.class, Byte.class))).get();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer>
----------
----------
13. WARNING in file:///test/__mbstate_t.java (at line 19)
public __mbstate_t(Pointer pointer) {
^^^^^^^
Pointer is a raw type. References to generic type Pointer should be parameterized
----------
14. WARNING in file:///test/__mbstate_t.java (at line 20)
super(pointer);
^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer
----------
15. WARNING in file:///test/__mbstate_t.java (at line 57)
public __value_union(Pointer pointer) {
^^^^^^^
Pointer is a raw type. References to generic type Pointer should be parameterized
----------
16. WARNING in file:///test/__mbstate_t.java (at line 58)
super(pointer);
^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer
----------
----------
17. WARNING in file:///test/_IO_FILE.java (at line 19)
public _IO_FILE(Pointer pointer) {
^^^^^^^
Pointer is a raw type. References to generic type Pointer should be parameterized
----------
18. WARNING in file:///test/_IO_FILE.java (at line 20)
super(pointer);
^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer
----------
19. ERROR in file:///test/_IO_FILE.java (at line 525)
@Array({15 * 4 - 4 * org.bridj.Pointer.SIZE - com.ochafik.lang.jnaerator.runtime.NativeSize.SIZE})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The value for annotation attribute Array.value must be a constant expression
----------
----------
20. WARNING in file:///test/__locale_struct.java (at line 19)
public __locale_struct(Pointer pointer) {
^^^^^^^
Pointer is a raw type. References to generic type Pointer should be parameterized
----------
21. WARNING in file:///test/__locale_struct.java (at line 20)
super(pointer);
^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer
----------
----------
22. WARNING in file:///test/__fsid_t.java (at line 18)
public __fsid_t(Pointer pointer) {
^^^^^^^
Pointer is a raw type. References to generic type Pointer should be parameterized
----------
23. WARNING in file:///test/__fsid_t.java (at line 19)
super(pointer);
^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer
----------
23 problems (1 error, 22 warnings)
```

I've tried to specify more memory to JNAerator appending `-Xmx2g` but even with 2g of ram result is the same. Is there some workaround?