Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
9456a024
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9456a024
编写于
2月 23, 2010
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6925932: (file) Path.endsWith can throw ArrayIndexOutOfBoundsException (unx)
Reviewed-by: chegar
上级
f7799fb3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
9 deletion
+31
-9
jdk/src/solaris/classes/sun/nio/fs/UnixPath.java
jdk/src/solaris/classes/sun/nio/fs/UnixPath.java
+9
-4
jdk/test/java/nio/file/Path/PathOps.java
jdk/test/java/nio/file/Path/PathOps.java
+22
-5
未找到文件。
jdk/src/solaris/classes/sun/nio/fs/UnixPath.java
浏览文件 @
9456a024
...
@@ -624,8 +624,11 @@ class UnixPath
...
@@ -624,8 +624,11 @@ class UnixPath
public
boolean
endsWith
(
Path
other
)
{
public
boolean
endsWith
(
Path
other
)
{
UnixPath
that
=
checkPath
(
other
);
UnixPath
that
=
checkPath
(
other
);
int
thisLen
=
path
.
length
;
int
thatLen
=
that
.
path
.
length
;
// other path is longer
// other path is longer
if
(
that
.
path
.
length
>
path
.
length
)
if
(
that
Len
>
thisLen
)
return
false
;
return
false
;
// other path is absolute so this path must be absolute
// other path is absolute so this path must be absolute
...
@@ -643,10 +646,10 @@ class UnixPath
...
@@ -643,10 +646,10 @@ class UnixPath
if
(
thatOffsetCount
==
thisOffsetCount
)
{
if
(
thatOffsetCount
==
thisOffsetCount
)
{
if
(
thisOffsetCount
==
0
)
if
(
thisOffsetCount
==
0
)
return
true
;
return
true
;
int
expectedLen
=
path
.
length
;
int
expectedLen
=
thisLen
;
if
(
this
.
isAbsolute
()
&&
!
that
.
isAbsolute
())
if
(
this
.
isAbsolute
()
&&
!
that
.
isAbsolute
())
expectedLen
--;
expectedLen
--;
if
(
that
.
path
.
length
!=
expectedLen
)
if
(
that
Len
!=
expectedLen
)
return
false
;
return
false
;
}
else
{
}
else
{
// this path has more elements so given path must be relative
// this path has more elements so given path must be relative
...
@@ -658,7 +661,9 @@ class UnixPath
...
@@ -658,7 +661,9 @@ class UnixPath
// compare bytes
// compare bytes
int
thisPos
=
offsets
[
thisOffsetCount
-
thatOffsetCount
];
int
thisPos
=
offsets
[
thisOffsetCount
-
thatOffsetCount
];
int
thatPos
=
that
.
offsets
[
0
];
int
thatPos
=
that
.
offsets
[
0
];
while
(
thatPos
<
that
.
path
.
length
)
{
if
((
thatLen
-
thatPos
)
!=
(
thisLen
-
thisPos
))
return
false
;
while
(
thatPos
<
thatLen
)
{
if
(
this
.
path
[
thisPos
++]
!=
that
.
path
[
thatPos
++])
if
(
this
.
path
[
thisPos
++]
!=
that
.
path
[
thatPos
++])
return
false
;
return
false
;
}
}
...
...
jdk/test/java/nio/file/Path/PathOps.java
浏览文件 @
9456a024
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
*/
*/
/* @test
/* @test
* @bug 4313887 6838333
* @bug 4313887 6838333
6925932
* @summary Unit test for java.nio.file.Path path operations
* @summary Unit test for java.nio.file.Path path operations
*/
*/
...
@@ -614,17 +614,34 @@ public class PathOps {
...
@@ -614,17 +614,34 @@ public class PathOps {
test
(
"/foo"
)
test
(
"/foo"
)
.
ends
(
"foo"
)
.
ends
(
"foo"
)
.
ends
(
"/foo"
)
.
ends
(
"/foo"
)
.
notEnds
(
"
/
"
);
.
notEnds
(
"
fool
"
);
test
(
"/foo/bar"
)
test
(
"/foo/bar"
)
.
ends
(
"bar"
)
.
ends
(
"bar"
)
.
ends
(
"foo/bar"
)
.
ends
(
"foo/bar"
)
.
ends
(
"/foo/bar"
)
.
ends
(
"/foo/bar"
)
.
notEnds
(
"/bar"
);
.
notEnds
(
"ar"
)
.
notEnds
(
"barack"
)
.
notEnds
(
"/bar"
)
.
notEnds
(
"o/bar"
);
test
(
"foo"
)
test
(
"foo"
)
.
ends
(
"foo"
);
.
ends
(
"foo"
)
.
notEnds
(
"oo"
)
.
notEnds
(
"oola"
);
test
(
"foo/bar"
)
test
(
"foo/bar"
)
.
ends
(
"bar"
)
.
ends
(
"bar"
)
.
ends
(
"foo/bar"
);
.
ends
(
"foo/bar"
)
.
notEnds
(
"r"
)
.
notEnds
(
"barmaid"
)
.
notEnds
(
"/bar"
);
test
(
"foo/bar/gus"
)
.
ends
(
"gus"
)
.
ends
(
"bar/gus"
)
.
ends
(
"foo/bar/gus"
)
.
notEnds
(
"g"
)
.
notEnds
(
"/gus"
)
.
notEnds
(
"r/gus"
)
.
notEnds
(
"barack/gus"
)
.
notEnds
(
"bar/gust"
);
// elements
// elements
test
(
"a/b/c"
)
test
(
"a/b/c"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录