--- old/src/share/classes/java/util/regex/Pattern.java 2011-06-02 22:53:31.000000000 -0700 +++ new/src/share/classes/java/util/regex/Pattern.java 2011-06-02 22:53:31.000000000 -0700 @@ -2497,7 +2497,10 @@ if (prev != null) { if (consume) next(); - return prev; + if (include) + return prev; + else + return prev.complement(); } break; default: @@ -2505,20 +2508,11 @@ break; } node = range(bits); - if (include) { - if (prev == null) { - prev = node; - } else { - if (prev != node) - prev = union(prev, node); - } + if (prev == null) { + prev = node; } else { - if (prev == null) { - prev = node.complement(); - } else { - if (prev != node) - prev = setDifference(prev, node); - } + if (prev != node) + prev = union(prev, node); } ch = peek(); } @@ -5162,16 +5156,6 @@ } /** - * Returns the set difference of two CharProperty nodes. - */ - private static CharProperty setDifference(final CharProperty lhs, - final CharProperty rhs) { - return new CharProperty() { - boolean isSatisfiedBy(int ch) { - return ! rhs.isSatisfiedBy(ch) && lhs.isSatisfiedBy(ch);}}; - } - - /** * Handles word boundaries. Includes a field to allow this one class to * deal with the different types of word boundaries we can match. The word * characters include underscores, letters, and digits. Non spacing marks