Identifying null characters in strings

500 views
Skip to first unread message

Louise Dennis

unread,
Oct 12, 2011, 11:55:18 AM10/12/11
to java-pa...@googlegroups.com
My application has to parse a string and to do this it uses a parser
generated using antlr.

When I run the application in java pathfinder I get errors in the
parsing. After some digging around in the antlr source code it seems
that these errors are being caused because java pathfinder's VM isn't
recognising \0 (or \000 or \u000) as the null character. Antlr's lexer
seems to be using \0 in a number of fixed strings in order to specify
special characters etc.

Is this a known bug? and does anyone have a fix either in terms of
settings for javapathfinder or in terms of some way of hacking the code
generated by antlr?

Louise Dennis

Peter Mehlitz

unread,
Oct 12, 2011, 12:57:48 PM10/12/11
to java-pa...@googlegroups.com
I'm not aware of any special treatment of \u0000 char values in Strings, and jpf-aprop executes antlr as part of the MethodTester. Can you give me a (preferably short) example of what fails?

-- Peter

Louise Dennis

unread,
Oct 12, 2011, 1:09:08 PM10/12/11
to java-pa...@googlegroups.com
The code sequence

String test = "\u0000";
System.err.println(test.length());
char ch = test.charAt(0);
System.err.println(Character.isISOControl(ch));

normally produces the output:

1
true

but:

2
false

When being executed within Java Pathfinder (version v6.0).

Louise

Peter Mehlitz

unread,
Oct 12, 2011, 3:54:39 PM10/12/11
to java-pa...@googlegroups.com
Thanks Louise, fixed.
It was a bug in gov.nasa.jpf.classfile.ClassFile, which created Strings as UTF-8, whereas it should have use modified UTF-8. Funny thing is the parsing actually got a tad faster.

-- Peter

Reply all
Reply to author
Forward
0 new messages