Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c50f281e
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看板
提交
c50f281e
编写于
3月 01, 2011
作者:
S
smarks
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7022624: use try-with-resources in java.io tests
Reviewed-by: alanb
上级
3aa63cac
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
57 addition
and
56 deletion
+57
-56
test/java/io/File/SetLastModified.java
test/java/io/File/SetLastModified.java
+3
-3
test/java/io/FileOutputStream/AtomicAppend.java
test/java/io/FileOutputStream/AtomicAppend.java
+5
-5
test/java/io/OutputStreamWriter/Encode.java
test/java/io/OutputStreamWriter/Encode.java
+23
-18
test/java/io/PrintStream/EncodingConstructor.java
test/java/io/PrintStream/EncodingConstructor.java
+3
-3
test/java/io/PrintStream/FailingConstructors.java
test/java/io/PrintStream/FailingConstructors.java
+9
-8
test/java/io/Serializable/evolution/RenamePackage/install/SerialDriver.java
...lizable/evolution/RenamePackage/install/SerialDriver.java
+7
-10
test/java/io/Serializable/evolution/RenamePackage/test/SerialDriver.java
...rializable/evolution/RenamePackage/test/SerialDriver.java
+7
-9
未找到文件。
test/java/io/File/SetLastModified.java
浏览文件 @
c50f281e
...
@@ -105,9 +105,9 @@ public class SetLastModified {
...
@@ -105,9 +105,9 @@ public class SetLastModified {
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
)
?
0L
:
3L
*
G
;
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
)
?
0L
:
3L
*
G
;
long
pos
=
0L
;
long
pos
=
0L
;
while
(
pos
<=
MAX_POSITION
)
{
while
(
pos
<=
MAX_POSITION
)
{
FileChannel
fc
=
new
FileOutputStream
(
f
).
getChannel
();
try
(
FileChannel
fc
=
new
FileOutputStream
(
f
).
getChannel
())
{
fc
.
position
(
pos
).
write
(
ByteBuffer
.
wrap
(
"x"
.
getBytes
()));
fc
.
position
(
pos
).
write
(
ByteBuffer
.
wrap
(
"x"
.
getBytes
()));
fc
.
close
();
}
ot
=
f
.
lastModified
();
ot
=
f
.
lastModified
();
System
.
out
.
format
(
"check with file size: %d\n"
,
f
.
length
());
System
.
out
.
format
(
"check with file size: %d\n"
,
f
.
length
());
if
(!
f
.
setLastModified
(
nt
))
if
(!
f
.
setLastModified
(
nt
))
...
...
test/java/io/FileOutputStream/AtomicAppend.java
浏览文件 @
c50f281e
...
@@ -47,12 +47,12 @@ public class AtomicAppend {
...
@@ -47,12 +47,12 @@ public class AtomicAppend {
for
(
int
i
=
0
;
i
<
nThreads
;
i
++)
for
(
int
i
=
0
;
i
<
nThreads
;
i
++)
es
.
execute
(
new
Runnable
()
{
public
void
run
()
{
es
.
execute
(
new
Runnable
()
{
public
void
run
()
{
try
{
try
{
FileOutputStream
s
=
new
FileOutputStream
(
file
,
true
);
try
(
FileOutputStream
s
=
new
FileOutputStream
(
file
,
true
))
{
for
(
int
j
=
0
;
j
<
1000
;
j
++)
{
for
(
int
j
=
0
;
j
<
1000
;
j
++)
{
s
.
write
((
int
)
'x'
);
s
.
write
((
int
)
'x'
);
s
.
flush
();
s
.
flush
();
}
}
}
s
.
close
();
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}}});
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}}});
es
.
shutdown
();
es
.
shutdown
();
es
.
awaitTermination
(
10L
,
TimeUnit
.
MINUTES
);
es
.
awaitTermination
(
10L
,
TimeUnit
.
MINUTES
);
...
...
test/java/io/OutputStreamWriter/Encode.java
浏览文件 @
c50f281e
...
@@ -35,8 +35,9 @@ public class Encode implements Runnable {
...
@@ -35,8 +35,9 @@ public class Encode implements Runnable {
new
Encode
();
new
Encode
();
}
}
final
ServerSocket
ss
=
new
ServerSocket
(
0
);
Encode
()
throws
Exception
{
Encode
()
throws
Exception
{
ss
=
new
ServerSocket
(
0
);
(
new
Thread
(
this
)).
start
();
(
new
Thread
(
this
)).
start
();
String
toEncode
=
"\uD800\uDC00 \uD801\uDC01 "
;
String
toEncode
=
"\uD800\uDC00 \uD801\uDC01 "
;
String
enc1
=
URLEncoder
.
encode
(
toEncode
,
"UTF-8"
);
String
enc1
=
URLEncoder
.
encode
(
toEncode
,
"UTF-8"
);
...
@@ -47,27 +48,31 @@ public class Encode implements Runnable {
...
@@ -47,27 +48,31 @@ public class Encode implements Runnable {
"/missing.nothtml"
;
"/missing.nothtml"
;
HttpURLConnection
uc
=
(
HttpURLConnection
)
new
URL
(
url
).
openConnection
();
HttpURLConnection
uc
=
(
HttpURLConnection
)
new
URL
(
url
).
openConnection
();
uc
.
connect
();
uc
.
connect
();
String
enc2
=
URLEncoder
.
encode
(
toEncode
,
"UTF-8"
);
try
{
if
(!
enc1
.
equals
(
enc2
))
String
enc2
=
URLEncoder
.
encode
(
toEncode
,
"UTF-8"
);
throw
new
RuntimeException
(
"test failed"
);
if
(!
enc1
.
equals
(
enc2
))
{
uc
.
disconnect
();
System
.
out
.
println
(
"test failed"
);
throw
new
RuntimeException
(
"test failed"
);
}
}
finally
{
uc
.
disconnect
();
}
}
}
ServerSocket
ss
;
public
void
run
()
{
public
void
run
()
{
try
{
try
(
ServerSocket
serv
=
ss
;
Socket
s
=
ss
.
accept
();
Socket
s
=
serv
.
accept
();
BufferedReader
in
=
new
BufferedReader
(
BufferedReader
in
=
new
InputStreamReader
(
s
.
getInputStream
()));
new
BufferedReader
(
new
InputStreamReader
(
s
.
getInputStream
())))
{
String
req
=
in
.
readLine
();
String
req
=
in
.
readLine
();
PrintStream
out
=
new
PrintStream
(
new
BufferedOutputStream
(
try
(
OutputStream
os
=
s
.
getOutputStream
();
s
.
getOutputStream
())
);
BufferedOutputStream
bos
=
new
BufferedOutputStream
(
os
);
out
.
print
(
"HTTP/1.1 403 Forbidden\r\n"
);
PrintStream
out
=
new
PrintStream
(
bos
))
out
.
print
(
"\r\n"
);
{
out
.
flush
(
);
out
.
print
(
"HTTP/1.1 403 Forbidden\r\n"
);
s
.
close
(
);
out
.
print
(
"\r\n"
);
ss
.
close
();
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
test/java/io/PrintStream/EncodingConstructor.java
浏览文件 @
c50f281e
...
@@ -34,11 +34,11 @@ public class EncodingConstructor {
...
@@ -34,11 +34,11 @@ public class EncodingConstructor {
public
static
void
main
(
String
args
[])
throws
Exception
{
public
static
void
main
(
String
args
[])
throws
Exception
{
ByteArrayOutputStream
bo
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
bo
=
new
ByteArrayOutputStream
();
PrintStream
ps
=
new
PrintStream
(
bo
,
false
,
"UTF-8"
);
String
s
=
"xyzzy"
;
String
s
=
"xyzzy"
;
int
n
=
s
.
length
();
int
n
=
s
.
length
();
ps
.
print
(
s
);
try
(
PrintStream
ps
=
new
PrintStream
(
bo
,
false
,
"UTF-8"
))
{
ps
.
close
();
ps
.
print
(
s
);
}
byte
[]
ba
=
bo
.
toByteArray
();
byte
[]
ba
=
bo
.
toByteArray
();
if
(
ba
.
length
!=
n
)
if
(
ba
.
length
!=
n
)
throw
new
Exception
(
"Length mismatch: "
+
n
+
" "
+
ba
.
length
);
throw
new
Exception
(
"Length mismatch: "
+
n
+
" "
+
ba
.
length
);
...
...
test/java/io/PrintStream/FailingConstructors.java
浏览文件 @
c50f281e
...
@@ -35,6 +35,8 @@ import java.io.FileNotFoundException;
...
@@ -35,6 +35,8 @@ import java.io.FileNotFoundException;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintStream
;
import
java.io.PrintStream
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
public
class
FailingConstructors
{
public
class
FailingConstructors
{
static
final
String
fileName
=
"FailingConstructorsTest"
;
static
final
String
fileName
=
"FailingConstructorsTest"
;
...
@@ -45,14 +47,13 @@ public class FailingConstructors {
...
@@ -45,14 +47,13 @@ public class FailingConstructors {
test
(
false
,
new
File
(
fileName
));
test
(
false
,
new
File
(
fileName
));
/* create the file and write its contents */
/* create the file and write its contents */
File
file
=
File
.
createTempFile
(
fileName
,
null
);
Path
path
=
Files
.
createTempFile
(
fileName
,
null
);
file
.
deleteOnExit
();
try
{
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
Files
.
write
(
path
,
FILE_CONTENTS
.
getBytes
());
fos
.
write
(
FILE_CONTENTS
.
getBytes
());
test
(
true
,
path
.
toFile
());
fos
.
close
();
}
finally
{
Files
.
delete
(
path
);
test
(
true
,
file
);
}
file
.
delete
();
}
}
private
static
void
test
(
boolean
exists
,
File
file
)
throws
Throwable
{
private
static
void
test
(
boolean
exists
,
File
file
)
throws
Throwable
{
...
...
test/java/io/Serializable/evolution/RenamePackage/install/SerialDriver.java
浏览文件 @
c50f281e
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
* @build install/SerialDriver.java test/SerialDriver.java extension/ExtendedObjectInputStream.java
* @build install/SerialDriver.java test/SerialDriver.java extension/ExtendedObjectInputStream.java
* @summary Enable resolveClass() to accommodate package renaming.
* @summary Enable resolveClass() to accommodate package renaming.
* This fix enables one to implement a resolveClass method that maps a
* This fix enables one to implement a resolveClass method that maps a
* Seriali
a
zable class within a serialization stream to the same class
* Serializable class within a serialization stream to the same class
* in a different package within the JVM runtime. See run shell script
* in a different package within the JVM runtime. See run shell script
* for instructions on how to run this test.
* for instructions on how to run this test.
*/
*/
...
@@ -86,16 +86,15 @@ public class SerialDriver implements Serializable {
...
@@ -86,16 +86,15 @@ public class SerialDriver implements Serializable {
File
f
=
new
File
(
"stream.ser"
);
File
f
=
new
File
(
"stream.ser"
);
if
(
serialize
)
{
if
(
serialize
)
{
// Serialize the subclass
// Serialize the subclass
try
{
try
(
FileOutputStream
fo
=
new
FileOutputStream
(
f
);
FileOutputStream
fo
=
new
FileOutputStream
(
f
);
ObjectOutputStream
so
=
new
ObjectOutputStream
(
fo
))
ObjectOutputStream
so
=
new
ObjectOutputStream
(
fo
);
{
so
.
writeObject
(
obj
);
so
.
writeObject
(
obj
);
/* Skip arrays since they do not work with rename yet.
/* Skip arrays since they do not work with rename yet.
The serialVersionUID changes due to the name change
The serialVersionUID changes due to the name change
and there is no way to set the serialVersionUID for an
and there is no way to set the serialVersionUID for an
array. */
array. */
so
.
writeObject
(
array
);
so
.
writeObject
(
array
);
so
.
flush
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
System
.
out
.
println
(
e
);
throw
e
;
throw
e
;
...
@@ -103,16 +102,14 @@ public class SerialDriver implements Serializable {
...
@@ -103,16 +102,14 @@ public class SerialDriver implements Serializable {
}
}
if
(
deserialize
)
{
if
(
deserialize
)
{
// Deserialize the subclass
// Deserialize the subclass
try
{
try
(
FileInputStream
fi
=
new
FileInputStream
(
f
);
FileInputStream
fi
=
new
FileInputStream
(
f
);
ExtendedObjectInputStream
si
=
new
ExtendedObjectInputStream
(
fi
))
ExtendedObjectInputStream
si
=
{
new
ExtendedObjectInputStream
(
fi
);
si
.
addRenamedClassName
(
"test.SerialDriver"
,
"install.SerialDriver"
);
si
.
addRenamedClassName
(
"test.SerialDriver"
,
"install.SerialDriver"
);
si
.
addRenamedClassName
(
"[Ltest.SerialDriver;"
,
si
.
addRenamedClassName
(
"[Ltest.SerialDriver;"
,
"[Linstall.SerialDriver"
);
"[Linstall.SerialDriver"
);
obj
=
(
SerialDriver
)
si
.
readObject
();
obj
=
(
SerialDriver
)
si
.
readObject
();
array
=
(
SerialDriver
[])
si
.
readObject
();
array
=
(
SerialDriver
[])
si
.
readObject
();
si
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
System
.
out
.
println
(
e
);
throw
e
;
throw
e
;
...
...
test/java/io/Serializable/evolution/RenamePackage/test/SerialDriver.java
浏览文件 @
c50f281e
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
* @build install/SerialDriver.java test/SerialDriver.java extension/ExtendedObjectInputStream.java
* @build install/SerialDriver.java test/SerialDriver.java extension/ExtendedObjectInputStream.java
* @summary Enable resolveClass() to accommodate package renaming.
* @summary Enable resolveClass() to accommodate package renaming.
* This fix enables one to implement a resolveClass method that maps a
* This fix enables one to implement a resolveClass method that maps a
* Seriali
a
zable class within a serialization stream to the same class
* Serializable class within a serialization stream to the same class
* in a different package within the JVM runtime. See run shell script
* in a different package within the JVM runtime. See run shell script
* for instructions on how to run this test.
* for instructions on how to run this test.
*/
*/
...
@@ -83,14 +83,13 @@ public class SerialDriver implements Serializable {
...
@@ -83,14 +83,13 @@ public class SerialDriver implements Serializable {
File
f
=
new
File
(
"stream.ser"
);
File
f
=
new
File
(
"stream.ser"
);
if
(
serialize
)
{
if
(
serialize
)
{
// Serialize the subclass
// Serialize the subclass
try
{
try
(
FileOutputStream
fo
=
new
FileOutputStream
(
f
);
FileOutputStream
fo
=
new
FileOutputStream
(
f
);
ObjectOutputStream
so
=
new
ObjectOutputStream
(
fo
))
ObjectOutputStream
so
=
new
ObjectOutputStream
(
fo
);
{
so
.
writeObject
(
obj
);
so
.
writeObject
(
obj
);
/* Comment out since renaming arrays does not work
/* Comment out since renaming arrays does not work
since it changes the serialVersionUID. */
since it changes the serialVersionUID. */
so
.
writeObject
(
array
);
so
.
writeObject
(
array
);
so
.
flush
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
System
.
out
.
println
(
e
);
throw
e
;
throw
e
;
...
@@ -98,16 +97,15 @@ public class SerialDriver implements Serializable {
...
@@ -98,16 +97,15 @@ public class SerialDriver implements Serializable {
}
}
if
(
deserialize
)
{
if
(
deserialize
)
{
// Deserialize the subclass
// Deserialize the subclass
try
{
try
(
FileInputStream
fi
=
new
FileInputStream
(
f
);
FileInputStream
fi
=
new
FileInputStream
(
f
);
ExtendedObjectInputStream
si
=
new
ExtendedObjectInputStream
(
fi
))
ExtendedObjectInputStream
si
=
new
ExtendedObjectInputStream
(
fi
);
{
si
.
addRenamedClassName
(
"install.SerialDriver"
,
si
.
addRenamedClassName
(
"install.SerialDriver"
,
"test.SerialDriver"
);
"test.SerialDriver"
);
si
.
addRenamedClassName
(
"[Linstall.SerialDriver;"
,
si
.
addRenamedClassName
(
"[Linstall.SerialDriver;"
,
"[Ltest.SerialDriver"
);
"[Ltest.SerialDriver"
);
obj
=
(
SerialDriver
)
si
.
readObject
();
obj
=
(
SerialDriver
)
si
.
readObject
();
array
=
(
SerialDriver
[])
si
.
readObject
();
array
=
(
SerialDriver
[])
si
.
readObject
();
si
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
System
.
out
.
println
(
e
);
throw
e
;
throw
e
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录