Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6bb7a48a
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看板
提交
6bb7a48a
编写于
11月 19, 2013
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8028589: Instrument tools/jar/JarEntryTime.java to make it easier to diagnose failures
Reviewed-by: chegar
上级
37b4280b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
16 deletion
+26
-16
test/tools/jar/JarEntryTime.java
test/tools/jar/JarEntryTime.java
+26
-16
未找到文件。
test/tools/jar/JarEntryTime.java
浏览文件 @
6bb7a48a
...
...
@@ -29,10 +29,15 @@
import
java.io.File
;
import
java.io.PrintWriter
;
import
java.
util.Dat
e
;
import
java.
nio.file.attribute.FileTim
e
;
import
sun.tools.jar.Main
;
public
class
JarEntryTime
{
// ZipEntry's mod date has 2 seconds precision: give extra time to
// allow for e.g. rounding/truncation and networked/samba drives.
static
final
long
PRECISION
=
10000L
;
static
boolean
cleanup
(
File
dir
)
throws
Throwable
{
boolean
rc
=
true
;
File
[]
x
=
dir
.
listFiles
();
...
...
@@ -88,9 +93,9 @@ public class JarEntryTime {
check
(
dirOuter
.
mkdir
());
check
(
dirInner
.
mkdir
());
File
fileInner
=
new
File
(
dirInner
,
"foo.txt"
);
PrintWriter
pw
=
new
PrintWriter
(
fileInner
);
pw
.
println
(
"hello, world"
);
pw
.
close
();
try
(
PrintWriter
pw
=
new
PrintWriter
(
fileInner
))
{
pw
.
println
(
"hello, world"
);
}
// Get the "now" from the "last-modified-time" of the last file we
// just created, instead of the "System.currentTimeMillis()", to
...
...
@@ -98,13 +103,10 @@ public class JarEntryTime {
final
long
now
=
fileInner
.
lastModified
();
final
long
earlier
=
now
-
(
60L
*
60L
*
6L
*
1000L
);
final
long
yesterday
=
now
-
(
60L
*
60L
*
24L
*
1000L
);
// ZipEntry's mod date has 2 seconds precision: give extra time to
// allow for e.g. rounding/truncation and networked/samba drives.
final
long
PRECISION
=
10000L
;
dirOuter
.
setLastModified
(
now
);
dirInner
.
setLastModified
(
yesterday
);
fileInner
.
setLastModified
(
earlier
);
check
(
dirOuter
.
setLastModified
(
now
)
);
check
(
dirInner
.
setLastModified
(
yesterday
)
);
check
(
fileInner
.
setLastModified
(
earlier
)
);
// Make a jar file from that directory structure
Main
jartool
=
new
Main
(
System
.
out
,
System
.
err
,
"jar"
);
...
...
@@ -122,9 +124,9 @@ public class JarEntryTime {
check
(
dirOuter
.
exists
());
check
(
dirInner
.
exists
());
check
(
fileInner
.
exists
());
check
(
Math
.
abs
(
dirOuter
.
lastModified
()
-
now
)
<=
PRECISION
);
check
(
Math
.
abs
(
dirInner
.
lastModified
()
-
yesterday
)
<=
PRECISION
);
check
(
Math
.
abs
(
fileInner
.
lastModified
()
-
earlier
)
<=
PRECISION
);
check
FileTime
(
dirOuter
.
lastModified
(),
now
);
check
FileTime
(
dirInner
.
lastModified
(),
yesterday
);
check
FileTime
(
fileInner
.
lastModified
(),
earlier
);
check
(
cleanup
(
dirInner
));
check
(
cleanup
(
dirOuter
));
...
...
@@ -135,9 +137,9 @@ public class JarEntryTime {
check
(
dirOuter
.
exists
());
check
(
dirInner
.
exists
());
check
(
fileInner
.
exists
());
check
(
Math
.
abs
(
dirOuter
.
lastModified
()
-
now
)
<=
PRECISION
);
check
(
Math
.
abs
(
dirInner
.
lastModified
()
-
now
)
<=
PRECISION
);
check
(
Math
.
abs
(
fileInner
.
lastModified
()
-
now
)
<=
PRECISION
);
check
FileTime
(
dirOuter
.
lastModified
(),
now
);
check
FileTime
(
dirInner
.
lastModified
(),
now
);
check
FileTime
(
fileInner
.
lastModified
(),
now
);
check
(
cleanup
(
dirInner
));
check
(
cleanup
(
dirOuter
));
...
...
@@ -145,6 +147,14 @@ public class JarEntryTime {
check
(
jarFile
.
delete
());
}
static
void
checkFileTime
(
long
now
,
long
original
)
{
if
(
Math
.
abs
(
now
-
original
)
>
PRECISION
)
{
System
.
out
.
format
(
"Extracted to %s, expected to be close to %s%n"
,
FileTime
.
fromMillis
(
now
),
FileTime
.
fromMillis
(
original
));
fail
();
}
}
//--------------------- Infrastructure ---------------------------
static
volatile
int
passed
=
0
,
failed
=
0
;
static
void
pass
()
{
passed
++;}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录