--- old/src/java.base/share/classes/java/nio/X-Buffer.java.template 2015-03-23 16:12:49.000000000 -0700 +++ new/src/java.base/share/classes/java/nio/X-Buffer.java.template 2015-03-23 16:12:49.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, 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 @@ -330,8 +330,9 @@ * If the capacity is a negative integer */ public static $Type$Buffer allocate(int capacity) { - if (capacity < 0) - throw new IllegalArgumentException(); + if (capacity < 0) { + throw negativeCapacityException(capacity); + } return new Heap$Type$Buffer(capacity, capacity); } @@ -760,8 +761,7 @@ * If this buffer is read-only */ public $Type$Buffer put($Type$Buffer src) { - if (src == this) - throw new IllegalArgumentException(); + checkSourceBufferNotThisBuffer(src); if (isReadOnly()) throw new ReadOnlyBufferException(); int n = src.remaining();