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

[JNAerator] issue with parsing defines #255

vbolshutkin opened this Issue Feb 6, 2012 · 2 comments


None yet
2 participants

vbolshutkin commented Feb 6, 2012


I'm trying to use JNAerator to generate BridJ code for my open-source project Octclipse and I've run to some issues with generation. For some of them I've found workarounds, but two of them, as I see are JNAerator's bugs:


When parsing line:

define FOOBAR ""

the output is the following
Failed to convert define 'FOOBAR => "":
java.lang.IllegalArgumentException: Expecting string, got ""


I could not use defines with spaces in my config.jnaerator. For instance, line

-DFOO=unsigned char

is appended directly to command line and JNAerator says, that file "char" was not found.
Workaround was to put all such defines to a separate file and include it first.

P.S. Even after all my workarounds and spikes(and resolving all defines in _jnaerator.preprocessed.c), JNAeration hangs with 100% CPU load. I am not sure that is really JNAerator bug, so it is not a good idea to post all the details here. But where can I ask for help regarding JNAeration?


This comment has been minimized.

vbolshutkin commented Feb 6, 2012

Here is the simpliest patch for 1st issue:

diff --git a/libraries/jnaerator/jnaerator-parser/src/main/java/com/ochafik/lang/jnaerator/parser/ b/libraries/jnaerator/jnaerator-parser/src/main/java/com/ochafik/lang/jnaerator/parser/
index 83fe250..6007b04 100644
--- a/libraries/jnaerator/jnaerator-parser/src/main/java/com/ochafik/lang/jnaerator/parser/
+++ b/libraries/jnaerator/jnaerator-parser/src/main/java/com/ochafik/lang/jnaerator/parser/

@@ -1350,7 +1350,7 @@ public abstract class Expression extends Element {
        public static Constant parseString(final String orig) {
             String string = orig;
            int len = string.length();
-           if (len <= 2 || string.charAt(0) != '"' || string.charAt(len - 1) != '"')
+           if (len < 2 || string.charAt(0) != '"' || string.charAt(len - 1) != '"')
                throw new IllegalArgumentException("Expecting string, got " + string);
            string = string.substring(1, len - 1);

This comment has been minimized.


ochafik commented Feb 12, 2012

Hi @ENargit,

Thanks a lot for your report, much appreciated !

I've fixed the empty string issue (thx for the patch).
About the -D switch : you can use double quotes around the whole argument : "-DFOO=unsigned char".

And regarding the 100% CPU hang you've faced, I would encourage you make sure you've read the FAQ and trouble-shooting pages (, and then to open an issue for the parser (if possible with the source code that reproduces the issue).
Please note that there are currently some known regressions in JNAerator 0.9.10-SNAPSHOT, though, and that I'm currently doing my best to iron them out :-S


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment