Verified to work on edge cases.
JBS: https://bugs.openjdk.java.net/browse/JDK-8198955 <https://bugs.openjdk.java.net/browse/JDK-8198955> Webrev: http://cr.openjdk.java.net/~jlaskey/8198955/webrev/index.html <http://cr.openjdk.java.net/~jlaskey/8198955/webrev/index.html>