The practice of having toString()in the ORO classes return the results of the last match or else throw null pointer exception is very detrimental to using the class in interpreted environments such as beanshell and probably jython. These environments call toString() as a matter of course after assigning a constructed object to a variable. It would be very helpful if the toString() method would return Object.toString() rather than throw a null pointer exception in the event that it is called before any match on the object.
The problem report is unclear. It refers to "the practice ... in ORO classes", but only Perl5Util throws a NullPointerException if toString() is called when there is no match. Perl5Util has to honor the MatchResult interface. Returning Object.toString() violate the MatchResult contract. However, it is undesirable to throw an exception when MatchResult requires group() to return null when there is no matched group and toString() returns group(0). Therefore, Perl5Util.toString() has been changed to return null if there is no match, which is the original intended behavior.
Closing report as it's been fixed for a number of months.