I modified the HelloWorld example slightly to use a different grammar and then print several sentence from the grammar using JSGFGrammar.dumpRandomSentences(path,number). My grammar, however, had a faulty rule that looks something like this:
Where if this grammar node were traversed there would be no way to to get to end node of an utterance. Loading and using the grammar in Sphinx4 works as expected (though I think a warning is needed), basically ignoring the rule because it is impossible to use it. However, if a bad grammar rule like this is present, it can cause an ArrayIndexOutOfBounds exception on line 287 of Grammar.java when using dumpRandomSentences(). I think there should be a try-catch statement around line 244 of the same file to print something about the nature of the problem.