--- old/src/java.base/share/classes/java/io/OutputStream.java 2017-11-21 12:22:40.000000000 -0800 +++ new/src/java.base/share/classes/java/io/OutputStream.java 2017-11-21 12:22:39.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package java.io; +import java.util.Objects; + /** * This abstract class is the superclass of all classes representing * an output stream of bytes. An output stream accepts output bytes @@ -104,14 +106,9 @@ * stream is closed. */ public void write(byte b[], int off, int len) throws IOException { - if (b == null) { - throw new NullPointerException(); - } else if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) > b.length) || ((off + len) < 0)) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return; - } + Objects.requireNonNull(b); + Objects.checkFromIndexSize(off, len, b.length); + // len == 0 condition implicitly handled by loop bounds for (int i = 0 ; i < len ; i++) { write(b[off + i]); }