diff --git a/src/java.base/share/classes/java/util/regex/Pattern.java b/src/java.base/share/classes/java/util/regex/Pattern.java --- a/src/java.base/share/classes/java/util/regex/Pattern.java +++ b/src/java.base/share/classes/java/util/regex/Pattern.java @@ -1097,8 +1097,11 @@ * The character sequence to be matched * * @return A new matcher for this pattern + * @throws NullPointerException if the specified {@code input} + * is {@code null}. */ public Matcher matcher(CharSequence input) { + Objects.requireNonNull(input); if (!compiled) { synchronized(this) { if (!compiled)