8164781: Pattern.asPredicate specification is incomplete
authorvtheeyarath
Mon, 09 Apr 2018 10:39:29 -0700
changeset 49554 f088ec60bed5
parent 49553 58cffb6ec13c
child 49555 12fe57c319e1
8164781: Pattern.asPredicate specification is incomplete Summary: Updated specification to reflect usage of find() Reviewed-by: psandoz
src/java.base/share/classes/java/util/regex/Pattern.java
test/jdk/java/util/regex/RegExTest.java
--- a/src/java.base/share/classes/java/util/regex/Pattern.java	Mon Apr 09 19:23:01 2018 +0200
+++ b/src/java.base/share/classes/java/util/regex/Pattern.java	Mon Apr 09 10:39:29 2018 -0700
@@ -5809,10 +5809,21 @@
     static final Node lastAccept = new LastNode();
 
     /**
-     * Creates a predicate which can be used to match a string.
+     * Creates a predicate that tests if this pattern is found in a given input
+     * string.
      *
-     * @return  The predicate which can be used for matching on a string
+     * @apiNote
+     * This method creates a predicate that behaves as if it creates a matcher
+     * from the input sequence and then calls {@code find}, for example a
+     * predicate of the form:
+     * <pre>{@code
+     *   s -> matcher(s).find();
+     * }</pre>
+     *
+     * @return  The predicate which can be used for finding a match on a
+     * subsequence of a string
      * @since   1.8
+     * @see Matcher#find
      */
     public Predicate<String> asPredicate() {
         return s -> matcher(s).find();
--- a/test/jdk/java/util/regex/RegExTest.java	Mon Apr 09 19:23:01 2018 +0200
+++ b/test/jdk/java/util/regex/RegExTest.java	Mon Apr 09 10:39:29 2018 -0700
@@ -4683,6 +4683,9 @@
         if (p.test("1234")) {
             failCount++;
         }
+        if (!p.test("word1234")) {
+            failCount++;
+        }
         report("Pattern.asPredicate");
     }