changeset 49698:f088ec60bed5

8164781: Pattern.asPredicate specification is incomplete Summary: Updated specification to reflect usage of find() Reviewed-by: psandoz
author vtheeyarath
date Mon, 09 Apr 2018 10:39:29 -0700
parents 58cffb6ec13c
children 12fe57c319e1
files src/java.base/share/classes/java/util/regex/Pattern.java test/jdk/java/util/regex/RegExTest.java
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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");
     }