I just observed this behavior;
Pattern p1 = Pattern.compile(\"^$\"); Matcher m1 = p1.matcher(\"\"); System.out.println(m1.matches()); /* true */ Pattern p2
If MULTILINE mode is activated then ^ matches at the beginning of input and after any line terminator except at the end of input.
Since you are at the end of input, ^ can't match in multiline mode.
^
This is surprising, even disgusting, but nevertheless according to its documentation.