Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e96cf10d
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e96cf10d
编写于
9月 21, 2012
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7199551: (bf) CharBuffer.append(CharSequence) throws BufferOverflowException for read-only buffer
Reviewed-by: iris, dxu, chegar
上级
01b3765e
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
213 addition
and
17 deletion
+213
-17
src/share/classes/java/nio/X-Buffer.java.template
src/share/classes/java/nio/X-Buffer.java.template
+4
-0
test/java/nio/Buffer/Basic-X.java.template
test/java/nio/Buffer/Basic-X.java.template
+26
-2
test/java/nio/Buffer/Basic.java
test/java/nio/Buffer/Basic.java
+1
-1
test/java/nio/Buffer/BasicByte.java
test/java/nio/Buffer/BasicByte.java
+26
-2
test/java/nio/Buffer/BasicChar.java
test/java/nio/Buffer/BasicChar.java
+26
-2
test/java/nio/Buffer/BasicDouble.java
test/java/nio/Buffer/BasicDouble.java
+26
-2
test/java/nio/Buffer/BasicFloat.java
test/java/nio/Buffer/BasicFloat.java
+26
-2
test/java/nio/Buffer/BasicInt.java
test/java/nio/Buffer/BasicInt.java
+26
-2
test/java/nio/Buffer/BasicLong.java
test/java/nio/Buffer/BasicLong.java
+26
-2
test/java/nio/Buffer/BasicShort.java
test/java/nio/Buffer/BasicShort.java
+26
-2
未找到文件。
src/share/classes/java/nio/X-Buffer.java.template
浏览文件 @
e96cf10d
...
...
@@ -741,6 +741,8 @@ public abstract class $Type$Buffer
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
();
...
...
@@ -888,6 +890,8 @@ public abstract class $Type$Buffer
*/
public
$
Type
$
Buffer
put
(
String
src
,
int
start
,
int
end
)
{
checkBounds
(
start
,
end
-
start
,
src
.
length
());
if
(
isReadOnly
())
throw
new
ReadOnlyBufferException
();
if
(
end
-
start
>
remaining
())
throw
new
BufferOverflowException
();
for
(
int
i
=
start
;
i
<
end
;
i
++)
...
...
test/java/nio/Buffer/Basic-X.java.template
浏览文件 @
e96cf10d
...
...
@@ -335,7 +335,7 @@ public class Basic$Type$
fail(problem + String.format(": x=%s y=%s", x, y), xb, yb);
}
private static void tryCatch(Buffer b, Class ex, Runnable thunk) {
private static void tryCatch(Buffer b, Class
<?>
ex, Runnable thunk) {
boolean caught = false;
try {
thunk.run();
...
...
@@ -350,7 +350,7 @@ public class Basic$Type$
fail(ex.getName() + " not thrown", b);
}
private static void tryCatch($type$ [] t, Class ex, Runnable thunk) {
private static void tryCatch($type$ [] t, Class
<?>
ex, Runnable thunk) {
tryCatch($Type$Buffer.wrap(t), ex, thunk);
}
...
...
@@ -681,6 +681,14 @@ public class Basic$Type$
bulkPutBuffer(rb);
}});
// put($Type$Buffer) should not change source position
final $Type$Buffer src = $Type$Buffer.allocate(1);
tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
public void run() {
rb.put(src);
}});
ck(src, src.position(), 0);
tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
public void run() {
rb.compact();
...
...
@@ -744,6 +752,22 @@ public class Basic$Type$
#end[byte]
#if[char]
// 7199551
tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
public void run() {
String s = new String(new char[rb.remaining() + 1]);
rb.put(s);
}});
tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
public void run() {
String s = new String(new char[rb.remaining() + 1]);
rb.append(s);
}});
#end[char]
if (rb.getClass().getName().startsWith("java.nio.Heap")) {
tryCatch(b, ReadOnlyBufferException.class, new Runnable() {
...
...
test/java/nio/Buffer/Basic.java
浏览文件 @
e96cf10d
...
...
@@ -25,7 +25,7 @@
* @summary Unit test for buffers
* @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 4490253 4523725
* 4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 6231529
* 6221101 6234263 6535542 6591971 6593946 6795561 7190219
* 6221101 6234263 6535542 6591971 6593946 6795561 7190219
7199551
* @author Mark Reinhold
*/
...
...
test/java/nio/Buffer/BasicByte.java
浏览文件 @
e96cf10d
...
...
@@ -335,7 +335,7 @@ public class BasicByte
fail
(
problem
+
String
.
format
(
": x=%s y=%s"
,
x
,
y
),
xb
,
yb
);
}
private
static
void
tryCatch
(
Buffer
b
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
Buffer
b
,
Class
<?>
ex
,
Runnable
thunk
)
{
boolean
caught
=
false
;
try
{
thunk
.
run
();
...
...
@@ -350,7 +350,7 @@ public class BasicByte
fail
(
ex
.
getName
()
+
" not thrown"
,
b
);
}
private
static
void
tryCatch
(
byte
[]
t
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
byte
[]
t
,
Class
<?>
ex
,
Runnable
thunk
)
{
tryCatch
(
ByteBuffer
.
wrap
(
t
),
ex
,
thunk
);
}
...
...
@@ -681,6 +681,14 @@ public class BasicByte
bulkPutBuffer
(
rb
);
}});
// put(ByteBuffer) should not change source position
final
ByteBuffer
src
=
ByteBuffer
.
allocate
(
1
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
put
(
src
);
}});
ck
(
src
,
src
.
position
(),
0
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
compact
();
...
...
@@ -744,6 +752,22 @@ public class BasicByte
if
(
rb
.
getClass
().
getName
().
startsWith
(
"java.nio.Heap"
))
{
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
...
...
test/java/nio/Buffer/BasicChar.java
浏览文件 @
e96cf10d
...
...
@@ -335,7 +335,7 @@ public class BasicChar
fail
(
problem
+
String
.
format
(
": x=%s y=%s"
,
x
,
y
),
xb
,
yb
);
}
private
static
void
tryCatch
(
Buffer
b
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
Buffer
b
,
Class
<?>
ex
,
Runnable
thunk
)
{
boolean
caught
=
false
;
try
{
thunk
.
run
();
...
...
@@ -350,7 +350,7 @@ public class BasicChar
fail
(
ex
.
getName
()
+
" not thrown"
,
b
);
}
private
static
void
tryCatch
(
char
[]
t
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
char
[]
t
,
Class
<?>
ex
,
Runnable
thunk
)
{
tryCatch
(
CharBuffer
.
wrap
(
t
),
ex
,
thunk
);
}
...
...
@@ -681,6 +681,14 @@ public class BasicChar
bulkPutBuffer
(
rb
);
}});
// put(CharBuffer) should not change source position
final
CharBuffer
src
=
CharBuffer
.
allocate
(
1
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
put
(
src
);
}});
ck
(
src
,
src
.
position
(),
0
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
compact
();
...
...
@@ -741,6 +749,22 @@ public class BasicChar
// 7199551
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
String
s
=
new
String
(
new
char
[
rb
.
remaining
()
+
1
]);
rb
.
put
(
s
);
}});
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
String
s
=
new
String
(
new
char
[
rb
.
remaining
()
+
1
]);
rb
.
append
(
s
);
}});
...
...
test/java/nio/Buffer/BasicDouble.java
浏览文件 @
e96cf10d
...
...
@@ -335,7 +335,7 @@ public class BasicDouble
fail
(
problem
+
String
.
format
(
": x=%s y=%s"
,
x
,
y
),
xb
,
yb
);
}
private
static
void
tryCatch
(
Buffer
b
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
Buffer
b
,
Class
<?>
ex
,
Runnable
thunk
)
{
boolean
caught
=
false
;
try
{
thunk
.
run
();
...
...
@@ -350,7 +350,7 @@ public class BasicDouble
fail
(
ex
.
getName
()
+
" not thrown"
,
b
);
}
private
static
void
tryCatch
(
double
[]
t
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
double
[]
t
,
Class
<?>
ex
,
Runnable
thunk
)
{
tryCatch
(
DoubleBuffer
.
wrap
(
t
),
ex
,
thunk
);
}
...
...
@@ -681,6 +681,14 @@ public class BasicDouble
bulkPutBuffer
(
rb
);
}});
// put(DoubleBuffer) should not change source position
final
DoubleBuffer
src
=
DoubleBuffer
.
allocate
(
1
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
put
(
src
);
}});
ck
(
src
,
src
.
position
(),
0
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
compact
();
...
...
@@ -727,6 +735,22 @@ public class BasicDouble
...
...
test/java/nio/Buffer/BasicFloat.java
浏览文件 @
e96cf10d
...
...
@@ -335,7 +335,7 @@ public class BasicFloat
fail
(
problem
+
String
.
format
(
": x=%s y=%s"
,
x
,
y
),
xb
,
yb
);
}
private
static
void
tryCatch
(
Buffer
b
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
Buffer
b
,
Class
<?>
ex
,
Runnable
thunk
)
{
boolean
caught
=
false
;
try
{
thunk
.
run
();
...
...
@@ -350,7 +350,7 @@ public class BasicFloat
fail
(
ex
.
getName
()
+
" not thrown"
,
b
);
}
private
static
void
tryCatch
(
float
[]
t
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
float
[]
t
,
Class
<?>
ex
,
Runnable
thunk
)
{
tryCatch
(
FloatBuffer
.
wrap
(
t
),
ex
,
thunk
);
}
...
...
@@ -681,6 +681,14 @@ public class BasicFloat
bulkPutBuffer
(
rb
);
}});
// put(FloatBuffer) should not change source position
final
FloatBuffer
src
=
FloatBuffer
.
allocate
(
1
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
put
(
src
);
}});
ck
(
src
,
src
.
position
(),
0
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
compact
();
...
...
@@ -727,6 +735,22 @@ public class BasicFloat
...
...
test/java/nio/Buffer/BasicInt.java
浏览文件 @
e96cf10d
...
...
@@ -335,7 +335,7 @@ public class BasicInt
fail
(
problem
+
String
.
format
(
": x=%s y=%s"
,
x
,
y
),
xb
,
yb
);
}
private
static
void
tryCatch
(
Buffer
b
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
Buffer
b
,
Class
<?>
ex
,
Runnable
thunk
)
{
boolean
caught
=
false
;
try
{
thunk
.
run
();
...
...
@@ -350,7 +350,7 @@ public class BasicInt
fail
(
ex
.
getName
()
+
" not thrown"
,
b
);
}
private
static
void
tryCatch
(
int
[]
t
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
int
[]
t
,
Class
<?>
ex
,
Runnable
thunk
)
{
tryCatch
(
IntBuffer
.
wrap
(
t
),
ex
,
thunk
);
}
...
...
@@ -681,6 +681,14 @@ public class BasicInt
bulkPutBuffer
(
rb
);
}});
// put(IntBuffer) should not change source position
final
IntBuffer
src
=
IntBuffer
.
allocate
(
1
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
put
(
src
);
}});
ck
(
src
,
src
.
position
(),
0
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
compact
();
...
...
@@ -727,6 +735,22 @@ public class BasicInt
...
...
test/java/nio/Buffer/BasicLong.java
浏览文件 @
e96cf10d
...
...
@@ -335,7 +335,7 @@ public class BasicLong
fail
(
problem
+
String
.
format
(
": x=%s y=%s"
,
x
,
y
),
xb
,
yb
);
}
private
static
void
tryCatch
(
Buffer
b
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
Buffer
b
,
Class
<?>
ex
,
Runnable
thunk
)
{
boolean
caught
=
false
;
try
{
thunk
.
run
();
...
...
@@ -350,7 +350,7 @@ public class BasicLong
fail
(
ex
.
getName
()
+
" not thrown"
,
b
);
}
private
static
void
tryCatch
(
long
[]
t
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
long
[]
t
,
Class
<?>
ex
,
Runnable
thunk
)
{
tryCatch
(
LongBuffer
.
wrap
(
t
),
ex
,
thunk
);
}
...
...
@@ -681,6 +681,14 @@ public class BasicLong
bulkPutBuffer
(
rb
);
}});
// put(LongBuffer) should not change source position
final
LongBuffer
src
=
LongBuffer
.
allocate
(
1
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
put
(
src
);
}});
ck
(
src
,
src
.
position
(),
0
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
compact
();
...
...
@@ -727,6 +735,22 @@ public class BasicLong
...
...
test/java/nio/Buffer/BasicShort.java
浏览文件 @
e96cf10d
...
...
@@ -335,7 +335,7 @@ public class BasicShort
fail
(
problem
+
String
.
format
(
": x=%s y=%s"
,
x
,
y
),
xb
,
yb
);
}
private
static
void
tryCatch
(
Buffer
b
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
Buffer
b
,
Class
<?>
ex
,
Runnable
thunk
)
{
boolean
caught
=
false
;
try
{
thunk
.
run
();
...
...
@@ -350,7 +350,7 @@ public class BasicShort
fail
(
ex
.
getName
()
+
" not thrown"
,
b
);
}
private
static
void
tryCatch
(
short
[]
t
,
Class
ex
,
Runnable
thunk
)
{
private
static
void
tryCatch
(
short
[]
t
,
Class
<?>
ex
,
Runnable
thunk
)
{
tryCatch
(
ShortBuffer
.
wrap
(
t
),
ex
,
thunk
);
}
...
...
@@ -681,6 +681,14 @@ public class BasicShort
bulkPutBuffer
(
rb
);
}});
// put(ShortBuffer) should not change source position
final
ShortBuffer
src
=
ShortBuffer
.
allocate
(
1
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
put
(
src
);
}});
ck
(
src
,
src
.
position
(),
0
);
tryCatch
(
b
,
ReadOnlyBufferException
.
class
,
new
Runnable
()
{
public
void
run
()
{
rb
.
compact
();
...
...
@@ -727,6 +735,22 @@ public class BasicShort
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录