src/java.base/share/classes/java/nio/X-Buffer.java.template
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2000, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 328,339 ****
*
* @throws IllegalArgumentException
* If the <tt>capacity</tt> is a negative integer
*/
public static $Type$Buffer allocate(int capacity) {
! if (capacity < 0)
! throw new IllegalArgumentException();
return new Heap$Type$Buffer(capacity, capacity);
}
/**
* Wraps $a$ $type$ array into a buffer.
--- 328,340 ----
*
* @throws IllegalArgumentException
* If the <tt>capacity</tt> is a negative integer
*/
public static $Type$Buffer allocate(int capacity) {
! if (capacity < 0) {
! throw negativeCapacityException(capacity);
! }
return new Heap$Type$Buffer(capacity, capacity);
}
/**
* Wraps $a$ $type$ array into a buffer.
*** 758,769 ****
*
* @throws ReadOnlyBufferException
* If this buffer is read-only
*/
public $Type$Buffer put($Type$Buffer src) {
! if (src == this)
! throw new IllegalArgumentException();
if (isReadOnly())
throw new ReadOnlyBufferException();
int n = src.remaining();
if (n > remaining())
throw new BufferOverflowException();
--- 759,769 ----
*
* @throws ReadOnlyBufferException
* If this buffer is read-only
*/
public $Type$Buffer put($Type$Buffer src) {
! checkSourceBufferNotThisBuffer(src);
if (isReadOnly())
throw new ReadOnlyBufferException();
int n = src.remaining();
if (n > remaining())
throw new BufferOverflowException();