Perforce-Inspired Patterns

Last night I started writing a class name matcher that uses Perforce-inspired patterns. Internally, those are converted to Java regexes. Using this matcher, it is a lot easier now to specify which classes in what packages should be excluded.

By now, I’ve found out that not the entire sun.* package has to be excluded, but actually just sun.reflect.*. I’m still working on java.*. Right now it seems like sun.util.*and sun.lang.*have to be excluded. I haven’t exactly considered the ramifications of that yet.

But more about those patterns. First of all, the entire string has to match, so ^ and $ for beginning and end are always implied. A ? matches a single character, a *matches zero or more characters but not a period (.), and \*\*\*truly matches zero or more characters. That way, * means just one package, \*\*\*means any number of packages. If a pattern is prefixed with !, then that match is negated. The matcher will indicate a match if there was at least one positive pattern that matched and no pattern that matched negatively.


About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in Concurrent Unit Testing. Bookmark the permalink.

Leave a Reply