Cross Reference: BasicShort.java
xref
: /
openjdk7
/
jdk
/
test
/
java
/
nio
/
Buffer
/
BasicShort.java
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
BasicShort.java revision 2005
0
N/A
/*
2273
N/A
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
0
N/A
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0
N/A
*
0
N/A
* This code is free software; you can redistribute it
and
/
or
modify it
0
N/A
* under the terms of the GNU General Public License version 2 only, as
0
N/A
* published by the Free Software Foundation.
0
N/A
*
0
N/A
* This code is distributed in the hope that it will be useful, but WITHOUT
0
N/A
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0
N/A
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0
N/A
* version 2 for more details (a copy is included in the LICENSE file that
0
N/A
* accompanied this code).
0
N/A
*
0
N/A
* You should have received a copy of the GNU General Public License version
0
N/A
* 2 along with this work; if not, write to the Free Software Foundation,
0
N/A
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0
N/A
*
1472
N/A
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
1472
N/A
* CA 95054 USA or visit www.sun.com if you need additional information or
1472
N/A
* have any questions.
0
N/A
*/
0
N/A
0
N/A
/* Type-specific source code for unit test
1879
N/A
*
1879
N/A
* Regenerate the BasicX classes via genBasic.sh whenever this file changes.
1879
N/A
* We check in the generated source files so that the test tree can be used
1879
N/A
* independently of the rest of the source tree.
1879
N/A
*/
1879
N/A
1879
N/A
// -- This file was mechanically generated: Do not edit! -- //
1879
N/A
1879
N/A
import
java
.
nio
.*;
1879
N/A
import
java
.
lang
.
reflect
.
Method
;
0
N/A
0
N/A
0
N/A
public
class
BasicShort
0
N/A
extends
Basic
0
N/A
{
0
N/A
0
N/A
private
static
final
short
[]
VALUES
= {
0
N/A
Short
.
MIN_VALUE
,
0
N/A
(
short
) -
1
,
0
N/A
(
short
)
0
,
0
N/A
(
short
)
1
,
0
N/A
Short
.
MAX_VALUE
,
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
};
0
N/A
0
N/A
private
static
void
relGet
(
ShortBuffer
b) {
0
N/A
int
n = b.
capacity
();
0
N/A
short
v;
0
N/A
for
(
int
i =
0
; i < n; i++)
0
N/A
ck
(b, (
long
)b.
get
(), (
long
)((
short
)
ic
(i)));
0
N/A
b.
rewind
();
0
N/A
}
0
N/A
0
N/A
private
static
void
relGet
(
ShortBuffer
b,
int
start
) {
0
N/A
int
n = b.
remaining
();
0
N/A
short
v;
0
N/A
for
(
int
i =
start
; i < n; i++)
0
N/A
ck
(b, (
long
)b.
get
(), (
long
)((
short
)
ic
(i)));
0
N/A
b.
rewind
();
0
N/A
}
0
N/A
0
N/A
private
static
void
absGet
(
ShortBuffer
b) {
0
N/A
int
n = b.
capacity
();
0
N/A
short
v;
0
N/A
for
(
int
i =
0
; i < n; i++)
0
N/A
ck
(b, (
long
)b.
get
(), (
long
)((
short
)
ic
(i)));
0
N/A
b.
rewind
();
0
N/A
}
0
N/A
0
N/A
private
static
void
bulkGet
(
ShortBuffer
b) {
0
N/A
int
n = b.
capacity
();
0
N/A
short
[] a =
new
short
[n +
7
];
0
N/A
b.
get
(a,
7
, n);
0
N/A
for
(
int
i =
0
; i < n; i++)
0
N/A
ck
(b, (
long
)a[i +
7
], (
long
)((
short
)
ic
(i)));
0
N/A
}
0
N/A
0
N/A
private
static
void
relPut
(
ShortBuffer
b) {
0
N/A
int
n = b.
capacity
();
0
N/A
b.
clear
();
0
N/A
for
(
int
i =
0
; i < n; i++)
0
N/A
b.
put
((
short
)
ic
(i));
0
N/A
b.
flip
();
0
N/A
}
0
N/A
0
N/A
private
static
void
absPut
(
ShortBuffer
b) {
0
N/A
int
n = b.
capacity
();
0
N/A
b.
clear
();
0
N/A
for
(
int
i =
0
; i < n; i++)
0
N/A
b.
put
(i, (
short
)
ic
(i));
0
N/A
b.
limit
(n);
0
N/A
b.
position
(
0
);
0
N/A
}
0
N/A
0
N/A
private
static
void
bulkPutArray
(
ShortBuffer
b) {
0
N/A
int
n = b.
capacity
();
0
N/A
b.
clear
();
0
N/A
short
[] a =
new
short
[n +
7
];
0
N/A
for
(
int
i =
0
; i < n; i++)
0
N/A
a[i +
7
] = (
short
)
ic
(i);
0
N/A
b.
put
(a,
7
, n);
0
N/A
b.
flip
();
0
N/A
}
0
N/A
0
N/A
private
static
void
bulkPutBuffer
(
ShortBuffer
b) {
0
N/A
int
n = b.
capacity
();
0
N/A
b.
clear
();
0
N/A
ShortBuffer
c =
ShortBuffer
.
allocate
(n +
7
);
0
N/A
c.
position
(
7
);
0
N/A
for
(
int
i =
0
; i < n; i++)
0
N/A
c.
put
((
short
)
ic
(i));
0
N/A
c.
flip
();
0
N/A
c.
position
(
7
);
0
N/A
b.
put
(c);
0
N/A
b.
flip
();
0
N/A
}
0
N/A
0
N/A
//6231529
0
N/A
private
static
void
callReset
(
ShortBuffer
b) {
0
N/A
b.
position
(
0
);
0
N/A
b.
mark
();
0
N/A
0
N/A
b.
duplicate
().
reset
();
0
N/A
b.
asReadOnlyBuffer
().
reset
();
0
N/A
}
0
N/A
0
N/A
0
N/A
0
N/A
// 6221101-6234263
0
N/A
0
N/A
private
static
void
putBuffer
() {
0
N/A
final
int
cap
=
10
;
0
N/A
0
N/A
ShortBuffer
direct1
=
ByteBuffer
.
allocateDirect
(
cap
).
asShortBuffer
();
0
N/A
ShortBuffer
nondirect1
=
ByteBuffer
.
allocate
(
cap
).
asShortBuffer
();
1969
N/A
direct1
.
put
(
nondirect1
);
0
N/A
0
N/A
ShortBuffer
direct2
=
ByteBuffer
.
allocateDirect
(
cap
).
asShortBuffer
();
0
N/A
ShortBuffer
nondirect2
=
ByteBuffer
.
allocate
(
cap
).
asShortBuffer
();
0
N/A
nondirect2
.
put
(
direct2
);
0
N/A
0
N/A
ShortBuffer
direct3
=
ByteBuffer
.
allocateDirect
(
cap
).
asShortBuffer
();
0
N/A
ShortBuffer
direct4
=
ByteBuffer
.
allocateDirect
(
cap
).
asShortBuffer
();
0
N/A
direct3
.
put
(
direct4
);
0
N/A
0
N/A
ShortBuffer
nondirect3
=
ByteBuffer
.
allocate
(
cap
).
asShortBuffer
();
0
N/A
ShortBuffer
nondirect4
=
ByteBuffer
.
allocate
(
cap
).
asShortBuffer
();
3237
N/A
nondirect3
.
put
(
nondirect4
);
3237
N/A
}
3237
N/A
3237
N/A
3237
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
private
static
void
checkSlice
(
ShortBuffer
b,
ShortBuffer
slice
) {
0
N/A
ck
(
slice
,
0
,
slice
.
position
());
0
N/A
ck
(
slice
, b.
remaining
(),
slice
.
limit
());
0
N/A
ck
(
slice
, b.
remaining
(),
slice
.
capacity
());
0
N/A
if
(b.
isDirect
() !=
slice
.
isDirect
())
0
N/A
fail
(
"Lost direction"
,
slice
);
0
N/A
if
(b.
isReadOnly
() !=
slice
.
isReadOnly
())
0
N/A
fail
(
"Lost read-only"
,
slice
);
0
N/A
}
304
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
private
static
void
fail
(
String
problem
,
0
N/A
ShortBuffer
xb
,
ShortBuffer
yb
,
0
N/A
short
x,
short
y) {
0
N/A
fail
(
problem
+
String
.
format
(
": x=%s y=%s"
, x, y),
xb
,
yb
);
0
N/A
}
0
N/A
0
N/A
private
static
void
tryCatch
(
Buffer
b,
Class
ex
,
Runnable
thunk
) {
0
N/A
boolean
caught
=
false
;
0
N/A
try
{
0
N/A
thunk
.
run
();
0
N/A
}
catch
(
Throwable
x) {
0
N/A
if
(
ex
.
isAssignableFrom
(x.
getClass
())) {
0
N/A
caught
=
true
;
0
N/A
}
else
{
0
N/A
fail
(x.
getMessage
() +
" not expected"
);
0
N/A
}
0
N/A
}
0
N/A
if
(!
caught
)
0
N/A
fail
(
ex
.
getName
() +
" not thrown"
, b);
0
N/A
}
0
N/A
0
N/A
private
static
void
tryCatch
(
short
[] t,
Class
ex
,
Runnable
thunk
) {
0
N/A
tryCatch
(
ShortBuffer
.
wrap
(t),
ex
,
thunk
);
2742
N/A
}
2742
N/A
2742
N/A
public
static
void
test
(
int
level
,
final
ShortBuffer
b,
boolean
direct
) {
2742
N/A
2742
N/A
show
(
level
, b);
2742
N/A
2742
N/A
if
(
direct
!= b.
isDirect
())
0
N/A
fail
(
"Wrong direction"
, b);
0
N/A
0
N/A
// Gets and puts
0
N/A
0
N/A
relPut
(b);
1739
N/A
relGet
(b);
0
N/A
absGet
(b);
0
N/A
bulkGet
(b);
0
N/A
0
N/A
absPut
(b);
0
N/A
relGet
(b);
0
N/A
absGet
(b);
0
N/A
bulkGet
(b);
0
N/A
0
N/A
bulkPutArray
(b);
0
N/A
relGet
(b);
0
N/A
0
N/A
bulkPutBuffer
(b);
0
N/A
relGet
(b);
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
// Compact
0
N/A
0
N/A
relPut
(b);
0
N/A
b.
position
(
13
);
0
N/A
b.
compact
();
0
N/A
b.
flip
();
0
N/A
relGet
(b,
13
);
0
N/A
0
N/A
// Exceptions
0
N/A
0
N/A
relPut
(b);
0
N/A
b.
limit
(b.
capacity
() /
2
);
0
N/A
b.
position
(b.
limit
());
0
N/A
0
N/A
tryCatch
(b,
BufferUnderflowException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
b.
get
();
0
N/A
}});
0
N/A
0
N/A
tryCatch
(b,
BufferOverflowException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
b.
put
((
short
)
42
);
0
N/A
}});
0
N/A
0
N/A
// The index must be non-negative and lesss than the buffer's limit.
0
N/A
tryCatch
(b,
IndexOutOfBoundsException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
b.
get
(b.
limit
());
0
N/A
}});
0
N/A
tryCatch
(b,
IndexOutOfBoundsException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
b.
get
(-
1
);
0
N/A
}});
0
N/A
0
N/A
tryCatch
(b,
IndexOutOfBoundsException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
b.
put
(b.
limit
(), (
short
)
42
);
0
N/A
}});
0
N/A
0
N/A
tryCatch
(b,
InvalidMarkException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
b.
position
(
0
);
0
N/A
b.
mark
();
0
N/A
b.
compact
();
0
N/A
b.
reset
();
0
N/A
}});
0
N/A
0
N/A
// Values
0
N/A
0
N/A
b.
clear
();
0
N/A
b.
put
((
short
)
0
);
0
N/A
b.
put
((
short
)-
1
);
0
N/A
b.
put
((
short
)
1
);
0
N/A
b.
put
(
Short
.
MAX_VALUE
);
0
N/A
b.
put
(
Short
.
MIN_VALUE
);
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
short
v;
0
N/A
b.
flip
();
0
N/A
ck
(b, b.
get
(),
0
);
0
N/A
ck
(b, b.
get
(), (
short
)-
1
);
1504
N/A
ck
(b, b.
get
(),
1
);
0
N/A
ck
(b, b.
get
(),
Short
.
MAX_VALUE
);
0
N/A
ck
(b, b.
get
(),
Short
.
MIN_VALUE
);
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
// Comparison
0
N/A
b.
rewind
();
0
N/A
ShortBuffer
b2
=
ShortBuffer
.
allocate
(b.
capacity
());
0
N/A
b2
.
put
(b);
0
N/A
b2
.
flip
();
0
N/A
b.
position
(
2
);
0
N/A
b2
.
position
(
2
);
0
N/A
if
(!b.
equals
(
b2
)) {
0
N/A
for
(
int
i =
2
; i < b.
limit
(); i++) {
0
N/A
short
x = b.
get
(i);
0
N/A
short
y =
b2
.
get
(i);
0
N/A
if
(x != y
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
)
0
N/A
out
.
println
(
"["
+ i +
"] "
+ x +
" != "
+ y);
0
N/A
}
0
N/A
fail
(
"Identical buffers not equal"
, b,
b2
);
0
N/A
}
0
N/A
if
(b.
compareTo
(
b2
) !=
0
)
0
N/A
fail
(
"Comparison to identical buffer != 0"
, b,
b2
);
0
N/A
0
N/A
b.
limit
(b.
limit
() +
1
);
0
N/A
b.
position
(b.
limit
() -
1
);
0
N/A
b.
put
((
short
)
99
);
0
N/A
b.
rewind
();
0
N/A
b2
.
rewind
();
0
N/A
if
(b.
equals
(
b2
))
0
N/A
fail
(
"Non-identical buffers equal"
, b,
b2
);
0
N/A
if
(b.
compareTo
(
b2
) <=
0
)
0
N/A
fail
(
"Comparison to shorter buffer <= 0"
, b,
b2
);
0
N/A
b.
limit
(b.
limit
() -
1
);
0
N/A
0
N/A
b.
put
(
2
, (
short
)
42
);
0
N/A
if
(b.
equals
(
b2
))
0
N/A
fail
(
"Non-identical buffers equal"
, b,
b2
);
0
N/A
if
(b.
compareTo
(
b2
) <=
0
)
0
N/A
fail
(
"Comparison to lesser buffer <= 0"
, b,
b2
);
1504
N/A
0
N/A
// Check equals and compareTo with interesting values
0
N/A
for
(
short
x :
VALUES
) {
0
N/A
ShortBuffer
xb
=
ShortBuffer
.
wrap
(
new
short
[] { x });
0
N/A
if
(
xb
.
compareTo
(
xb
) !=
0
) {
0
N/A
fail
(
"compareTo not reflexive"
,
xb
,
xb
, x, x);
0
N/A
}
0
N/A
if
(!
xb
.
equals
(
xb
)) {
0
N/A
fail
(
"equals not reflexive"
,
xb
,
xb
, x, x);
0
N/A
}
0
N/A
for
(
short
y :
VALUES
) {
0
N/A
ShortBuffer
yb
=
ShortBuffer
.
wrap
(
new
short
[] { y });
0
N/A
if
(
xb
.
compareTo
(
yb
) != -
yb
.
compareTo
(
xb
)) {
0
N/A
fail
(
"compareTo not anti-symmetric"
,
0
N/A
xb
,
yb
, x, y);
0
N/A
}
0
N/A
if
((
xb
.
compareTo
(
yb
) ==
0
) !=
xb
.
equals
(
yb
)) {
0
N/A
fail
(
"compareTo inconsistent with equals"
,
0
N/A
xb
,
yb
, x, y);
0
N/A
}
0
N/A
if
(
xb
.
compareTo
(
yb
) !=
Short
.
compare
(x, y)) {
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
fail
(
"Incorrect results for ShortBuffer.compareTo"
,
0
N/A
xb
,
yb
, x, y);
0
N/A
}
0
N/A
if
(
xb
.
equals
(
yb
) != ((x == y) || ((x != x) && (y != y)))) {
0
N/A
fail
(
"Incorrect results for ShortBuffer.equals"
,
0
N/A
xb
,
yb
, x, y);
0
N/A
}
0
N/A
}
0
N/A
}
0
N/A
0
N/A
// Sub, dup
0
N/A
0
N/A
relPut
(b);
0
N/A
relGet
(b.
duplicate
());
0
N/A
b.
position
(
13
);
0
N/A
relGet
(b.
duplicate
(),
13
);
0
N/A
relGet
(b.
duplicate
().
slice
(),
13
);
0
N/A
relGet
(b.
slice
(),
13
);
0
N/A
relGet
(b.
slice
().
duplicate
(),
13
);
0
N/A
0
N/A
// Slice
0
N/A
0
N/A
b.
position
(
5
);
0
N/A
ShortBuffer
sb
= b.
slice
();
0
N/A
checkSlice
(b,
sb
);
0
N/A
b.
position
(
0
);
0
N/A
ShortBuffer
sb2
=
sb
.
slice
();
0
N/A
checkSlice
(
sb
,
sb2
);
0
N/A
0
N/A
if
(!
sb
.
equals
(
sb2
))
0
N/A
fail
(
"Sliced slices do not match"
,
sb
,
sb2
);
0
N/A
if
((
sb
.
hasArray
()) && (
sb
.
arrayOffset
() !=
sb2
.
arrayOffset
()))
0
N/A
fail
(
"Array offsets do not match: "
0
N/A
+
sb
.
arrayOffset
() +
" != "
+
sb2
.
arrayOffset
(),
sb
,
sb2
);
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
// Read-only views
0
N/A
0
N/A
b.
rewind
();
0
N/A
final
ShortBuffer
rb
= b.
asReadOnlyBuffer
();
0
N/A
if
(!b.
equals
(
rb
))
0
N/A
fail
(
"Buffer not equal to read-only view"
, b,
rb
);
0
N/A
show
(
level
+
1
,
rb
);
0
N/A
0
N/A
tryCatch
(b,
ReadOnlyBufferException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
relPut
(
rb
);
0
N/A
}});
0
N/A
0
N/A
tryCatch
(b,
ReadOnlyBufferException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
absPut
(
rb
);
0
N/A
}});
0
N/A
0
N/A
tryCatch
(b,
ReadOnlyBufferException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
bulkPutArray
(
rb
);
0
N/A
}});
0
N/A
0
N/A
tryCatch
(b,
ReadOnlyBufferException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
bulkPutBuffer
(
rb
);
0
N/A
}});
0
N/A
0
N/A
tryCatch
(b,
ReadOnlyBufferException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
rb
.
compact
();
0
N/A
}});
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
if
(
rb
.
getClass
().
getName
().
startsWith
(
"java.nio.Heap"
)) {
0
N/A
0
N/A
tryCatch
(b,
ReadOnlyBufferException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
rb
.
array
();
0
N/A
}});
0
N/A
0
N/A
tryCatch
(b,
ReadOnlyBufferException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
rb
.
arrayOffset
();
0
N/A
}});
0
N/A
0
N/A
if
(
rb
.
hasArray
())
0
N/A
fail
(
"Read-only heap buffer's backing array is accessible"
,
0
N/A
rb
);
0
N/A
0
N/A
}
0
N/A
0
N/A
// Bulk puts from read-only buffers
0
N/A
0
N/A
b.
clear
();
0
N/A
rb
.
rewind
();
0
N/A
b.
put
(
rb
);
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
relPut
(b);
// Required by testViews
0
N/A
0
N/A
}
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
public
static
void
test
(
final
short
[]
ba
) {
0
N/A
int
offset
=
47
;
0
N/A
int
length
=
900
;
0
N/A
final
ShortBuffer
b =
ShortBuffer
.
wrap
(
ba
,
offset
,
length
);
0
N/A
show
(
0
, b);
0
N/A
ck
(b, b.
capacity
(),
ba
.
length
);
0
N/A
ck
(b, b.
position
(),
offset
);
0
N/A
ck
(b, b.
limit
(),
offset
+
length
);
0
N/A
0
N/A
// The offset must be non-negative and no larger than <array.length>.
0
N/A
tryCatch
(
ba
,
IndexOutOfBoundsException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
ShortBuffer
.
wrap
(
ba
, -
1
,
ba
.
length
);
0
N/A
}});
0
N/A
tryCatch
(
ba
,
IndexOutOfBoundsException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
ShortBuffer
.
wrap
(
ba
,
ba
.
length
+
1
,
ba
.
length
);
0
N/A
}});
0
N/A
tryCatch
(
ba
,
IndexOutOfBoundsException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
ShortBuffer
.
wrap
(
ba
,
0
, -
1
);
0
N/A
}});
0
N/A
tryCatch
(
ba
,
IndexOutOfBoundsException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
ShortBuffer
.
wrap
(
ba
,
0
,
ba
.
length
+
1
);
0
N/A
}});
0
N/A
0
N/A
// A NullPointerException will be thrown if the array is null.
0
N/A
tryCatch
(
ba
,
NullPointerException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
ShortBuffer
.
wrap
((
short
[])
null
,
0
,
5
);
0
N/A
}});
0
N/A
tryCatch
(
ba
,
NullPointerException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
ShortBuffer
.
wrap
((
short
[])
null
);
0
N/A
}});
0
N/A
}
0
N/A
0
N/A
private
static
void
testAllocate
() {
0
N/A
// An IllegalArgumentException will be thrown for negative capacities.
0
N/A
tryCatch
((
Buffer
)
null
,
IllegalArgumentException
.
class
,
new
Runnable
() {
0
N/A
public
void
run
() {
0
N/A
ShortBuffer
.
allocate
(-
1
);
0
N/A
}});
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
}
0
N/A
0
N/A
public
static
void
test
() {
0
N/A
testAllocate
();
0
N/A
test
(
0
,
ShortBuffer
.
allocate
(
7
*
1024
),
false
);
0
N/A
test
(
0
,
ShortBuffer
.
wrap
(
new
short
[
7
*
1024
],
0
,
7
*
1024
),
false
);
0
N/A
test
(
new
short
[
1024
]);
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
0
N/A
callReset
(
ShortBuffer
.
allocate
(
10
));
0
N/A
0
N/A
0
N/A
0
N/A
putBuffer
();
0
N/A
0
N/A
}
0
N/A
0
N/A
}
0
N/A