Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
d363c21d
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看板
提交
d363c21d
编写于
14年前
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6962419: TEST_BUG: java_io tests fails in samevm mode
Reviewed-by: ohair, sherman
上级
47d4546f
无相关合并请求
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
214 addition
and
210 deletion
+214
-210
test/ProblemList.txt
test/ProblemList.txt
+0
-71
test/java/io/BufferedReader/BigMark.java
test/java/io/BufferedReader/BigMark.java
+2
-0
test/java/io/BufferedReader/ReadLineSync.java
test/java/io/BufferedReader/ReadLineSync.java
+11
-7
test/java/io/DataInputStream/OpsAfterClose.java
test/java/io/DataInputStream/OpsAfterClose.java
+12
-6
test/java/io/DataInputStream/ReadFully.java
test/java/io/DataInputStream/ReadFully.java
+1
-0
test/java/io/File/DeleteOnExit.java
test/java/io/File/DeleteOnExit.java
+3
-1
test/java/io/File/DeleteOnExitNPE.java
test/java/io/File/DeleteOnExitNPE.java
+2
-1
test/java/io/File/IsHidden.java
test/java/io/File/IsHidden.java
+11
-6
test/java/io/FileInputStream/LeadingSlash.java
test/java/io/FileInputStream/LeadingSlash.java
+2
-2
test/java/io/InputStream/OpsAfterClose.java
test/java/io/InputStream/OpsAfterClose.java
+21
-9
test/java/io/InputStream/ReadParams.java
test/java/io/InputStream/ReadParams.java
+1
-0
test/java/io/InputStreamReader/GrowAfterEOF.java
test/java/io/InputStreamReader/GrowAfterEOF.java
+27
-20
test/java/io/ObjectInputStream/ResolveProxyClass.java
test/java/io/ObjectInputStream/ResolveProxyClass.java
+1
-1
test/java/io/RandomAccessFile/EOF.java
test/java/io/RandomAccessFile/EOF.java
+9
-5
test/java/io/RandomAccessFile/ParameterCheck.java
test/java/io/RandomAccessFile/ParameterCheck.java
+4
-1
test/java/io/RandomAccessFile/ReadLine.java
test/java/io/RandomAccessFile/ReadLine.java
+21
-17
test/java/io/RandomAccessFile/Seek.java
test/java/io/RandomAccessFile/Seek.java
+2
-0
test/java/io/RandomAccessFile/WriteBytesChars.java
test/java/io/RandomAccessFile/WriteBytesChars.java
+3
-2
test/java/io/RandomAccessFile/WriteUTF.java
test/java/io/RandomAccessFile/WriteUTF.java
+2
-1
test/java/io/RandomAccessFile/skipBytes/SkipBytes.java
test/java/io/RandomAccessFile/skipBytes/SkipBytes.java
+12
-8
test/java/io/Reader/Skip.java
test/java/io/Reader/Skip.java
+9
-5
test/java/io/Reader/SkipNegative.java
test/java/io/Reader/SkipNegative.java
+2
-0
test/java/io/StreamTokenizer/Comment.java
test/java/io/StreamTokenizer/Comment.java
+34
-29
test/java/io/readBytes/ReadBytesBounds.java
test/java/io/readBytes/ReadBytesBounds.java
+22
-18
未找到文件。
test/ProblemList.txt
浏览文件 @
d363c21d
...
...
@@ -187,73 +187,6 @@ java/beans/XMLEncoder/6329581/Test6329581.java generic-all
############################################################################
# jdk_io
# Many of these tests have a tendency to leave input streams open, which
# will cause following tests to be failures when used in samevm mode.
# Should be othervm, or corrected for samevm, fails with samevm:
java/io/BufferedReader/BigMark.java generic-all
java/io/BufferedReader/ReadLineSync.java generic-all
# Windows samevm issues? triggers other tests to fail, missing close() on f.txt?
java/io/DataInputStream/OpsAfterClose.java generic-all
# Windows 32bit samevm failure: RuntimeException: File.getFreeSpace() failed
java/io/File/MaxPathLength.java generic-all
# Should be othervm, or corrected for samevm, fails with samevm:
java/io/File/DeleteOnExit.java generic-all
java/io/File/DeleteOnExitLong.java generic-all
java/io/File/DeleteOnExitNPE.java generic-all
java/io/File/IsHidden.java generic-all
java/io/FileDescriptor/FileChannelFDTest.java generic-all
java/io/FileDescriptor/Finalize.java generic-all
java/io/FileInputStream/FinalizeShdCallClose.java generic-all
# Known to cause samevm issues on windows, other tests fail, missing close()?
java/io/FileInputStream/OpsAfterClose.java generic-all
# Should be othervm, or corrected for samevm, fails with samevm:
java/io/FileOutputStream/FinalizeShdCallClose.java generic-all
# Known to cause samevm issues on windows, other tests fail, missing close()?
java/io/FileOutputStream/OpsAfterClose.java generic-all
# Windows samevm issues? triggers other tests to fail, missing close() on f.txt?
java/io/InputStream/OpsAfterClose.java generic-all
# Missing close() on x.ReadBounds file? Windows samevm issues
java/io/InputStream/ReadParams.java generic-all
# Known to cause samevm issues on windows, other tests fail, missing close()?
java/io/InputStreamReader/GrowAfterEOF.java generic-all
# Should be othervm, or corrected for samevm, fails with samevm:
java/io/ObjectInputStream/ResolveProxyClass.java generic-all
# Not doing a close() on x.ParameterCheck file? windows samevm cascade error
java/io/RandomAccessFile/ParameterCheck.java generic-all
# Not doing a close on x.ReadLine file? windows cascade samevm problems
java/io/RandomAccessFile/ReadLine.java generic-all
# Not doing close on file input x.WriteByteChars, windows samevm problems
java/io/RandomAccessFile/WriteBytesChars.java generic-all
# Not doing close on file input x.WriteUTF, windows samevm problems
java/io/RandomAccessFile/WriteUTF.java generic-all
# Possibly, not doing a close() on input.txt, windows samevm issues.
java/io/RandomAccessFile/skipBytes/SkipBytes.java generic-all
java/io/readBytes/MemoryLeak.java generic-all
java/io/readBytes/ReadBytesBounds.java generic-all
# Possibly not doing a close() on input.txt, windows samevm issues.
java/io/StreamTokenizer/Comment.java generic-all
############################################################################
# jdk_lang
# Times out on solaris 10 sparc
...
...
@@ -593,10 +526,6 @@ java/nio/channels/Selector/Wakeup.java windows-all
com/sun/nio/sctp/SctpChannel/Send.java generic-all
com/sun/nio/sctp/SctpChannel/Shutdown.java generic-all
# Fails on Windows 2000, Can't delete test directory .\x.SetLastModified.dir
# at SetLastModified.main(SetLastModified.java:107)
java/io/File/SetLastModified.java generic-all
# Fails on Windows 2000, times out
java/nio/channels/FileChannel/Transfer.java generic-all
...
...
This diff is collapsed.
Click to expand it.
test/java/io/BufferedReader/BigMark.java
浏览文件 @
d363c21d
...
...
@@ -25,6 +25,8 @@
@summary BufferedReader should throw an OutOfMemoryError when the
read-ahead limit is very large
@bug 6350733
@build BigMark
@run main/othervm BigMark
*/
import
java.io.*
;
...
...
This diff is collapsed.
Click to expand it.
test/java/io/BufferedReader/ReadLineSync.java
浏览文件 @
d363c21d
...
...
@@ -46,16 +46,20 @@ public class ReadLineSync {
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
f
));
int
threadCount
=
2
;
try
{
int
threadCount
=
2
;
ExecutorService
es
=
Executors
.
newFixedThreadPool
(
threadCount
);
ExecutorService
es
=
Executors
.
newFixedThreadPool
(
threadCount
);
for
(
int
i
=
0
;
i
<
threadCount
;
i
++)
es
.
execute
(
new
BufferedReaderConsumer
(
reader
));
for
(
int
i
=
0
;
i
<
threadCount
;
i
++)
es
.
execute
(
new
BufferedReaderConsumer
(
reader
));
// Wait for the tasks to complete
es
.
shutdown
();
while
(!
es
.
awaitTermination
(
60
,
TimeUnit
.
SECONDS
));
// Wait for the tasks to complete
es
.
shutdown
();
while
(!
es
.
awaitTermination
(
60
,
TimeUnit
.
SECONDS
));
}
finally
{
reader
.
close
();
}
}
static
class
BufferedReaderConsumer
extends
Thread
{
...
...
This diff is collapsed.
Click to expand it.
test/java/io/DataInputStream/OpsAfterClose.java
浏览文件 @
d363c21d
...
...
@@ -244,13 +244,19 @@ public enum OpsAfterClose {
f
.
deleteOnExit
();
FileInputStream
fis
=
new
FileInputStream
(
f
);
DataInputStream
dis
=
new
DataInputStream
(
new
FileInputStream
(
f
));
if
(
testDataInputStream
(
dis
))
{
failed
=
true
;
try
{
DataInputStream
dis
=
new
DataInputStream
(
new
FileInputStream
(
f
));
try
{
if
(
testDataInputStream
(
dis
))
{
failed
=
true
;
}
}
finally
{
dis
.
close
();
}
}
finally
{
fis
.
close
();
}
}
private
static
boolean
testDataInputStream
(
DataInputStream
is
)
...
...
This diff is collapsed.
Click to expand it.
test/java/io/DataInputStream/ReadFully.java
浏览文件 @
d363c21d
...
...
@@ -43,6 +43,7 @@ public class ReadFully {
}
catch
(
IndexOutOfBoundsException
ie
)
{
caughtException
=
true
;
}
finally
{
dis
.
close
();
if
(!
caughtException
)
throw
new
RuntimeException
(
"Test failed"
);
}
...
...
This diff is collapsed.
Click to expand it.
test/java/io/File/DeleteOnExit.java
浏览文件 @
d363c21d
...
...
@@ -48,7 +48,9 @@ public class DeleteOnExit {
public
static
void
main
(
String
args
[])
throws
Exception
{
if
(
args
.
length
==
0
)
{
Runtime
.
getRuntime
().
exec
(
java
+
" DeleteOnExit -test"
).
waitFor
();
String
cmd
=
java
+
" -classpath "
+
System
.
getProperty
(
"test.classes"
)
+
" DeleteOnExit -test"
;
Runtime
.
getRuntime
().
exec
(
cmd
).
waitFor
();
if
(
file1
.
exists
()
||
file2
.
exists
()
||
file3
.
exists
()
||
dir
.
exists
()
||
file4
.
exists
()
||
file5
.
exists
()
||
file6
.
exists
()
||
file7
.
exists
())
{
...
...
This diff is collapsed.
Click to expand it.
test/java/io/File/DeleteOnExitNPE.java
浏览文件 @
d363c21d
...
...
@@ -45,7 +45,8 @@ public class DeleteOnExitNPE implements Runnable
public
static
void
runTest
()
throws
Exception
{
String
cmd
=
System
.
getProperty
(
"java.home"
)
+
File
.
separator
+
"bin"
+
File
.
separator
+
"java"
;
"bin"
+
File
.
separator
+
"java"
+
" -classpath "
+
System
.
getProperty
(
"test.classes"
);
Process
process
=
Runtime
.
getRuntime
().
exec
(
cmd
+
" DeleteOnExitNPE -test"
);
BufferedReader
isReader
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
BufferedReader
esReader
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getErrorStream
()));
...
...
This diff is collapsed.
Click to expand it.
test/java/io/File/IsHidden.java
浏览文件 @
d363c21d
...
...
@@ -27,7 +27,7 @@
*/
import
java.io.*
;
import
java.nio.file.attribute.DosFileAttributeView
;
public
class
IsHidden
{
...
...
@@ -41,15 +41,20 @@ public class IsHidden {
System
.
err
.
println
(
path
+
" ==> "
+
x
);
}
private
static
void
setHidden
(
File
f
,
boolean
value
)
throws
IOException
{
f
.
toPath
().
getFileAttributeView
(
DosFileAttributeView
.
class
).
setHidden
(
value
);
}
private
static
void
testWin32
()
throws
Exception
{
File
f
=
new
File
(
dir
,
"test"
);
f
.
deleteOnExit
();
f
.
createNewFile
();
String
name
=
f
.
getCanonicalPath
();
Process
p
=
Runtime
.
getRuntime
().
exec
(
"cmd.exe /c attrib +H "
+
name
);
p
.
waitFor
();
ck
(
name
,
true
);
setHidden
(
f
,
true
);
try
{
ck
(
f
.
getPath
(),
true
);
}
finally
{
setHidden
(
f
,
false
);
}
ck
(
".foo"
,
false
);
ck
(
"foo"
,
false
);
}
...
...
This diff is collapsed.
Click to expand it.
test/java/io/FileInputStream/LeadingSlash.java
浏览文件 @
d363c21d
...
...
@@ -36,8 +36,8 @@ public class LeadingSlash {
File
file
=
null
;
try
{
file
=
File
.
createTempFile
(
"bug"
,
"4487368"
);
new
FileInputStream
(
"\\"
+
file
.
getPath
());
new
FileOutputStream
(
"\\"
+
file
.
getPath
());
new
FileInputStream
(
"\\"
+
file
.
getPath
())
.
close
()
;
new
FileOutputStream
(
"\\"
+
file
.
getPath
())
.
close
()
;
}
finally
{
if
(
file
!=
null
)
file
.
delete
();
...
...
This diff is collapsed.
Click to expand it.
test/java/io/InputStream/OpsAfterClose.java
浏览文件 @
d363c21d
...
...
@@ -125,23 +125,35 @@ public enum OpsAfterClose {
f
.
deleteOnExit
();
FileInputStream
fis
=
new
FileInputStream
(
f
);
if
(
testInputStream
(
fis
))
{
failed
=
true
;
}
if
(
testFileInputStream
(
fis
))
{
failed
=
true
;
try
{
if
(
testInputStream
(
fis
))
{
failed
=
true
;
}
if
(
testFileInputStream
(
fis
))
{
failed
=
true
;
}
}
finally
{
fis
.
close
();
}
BufferedInputStream
bs
=
new
BufferedInputStream
(
new
FileInputStream
(
f
));
if
(
testInputStream
(
bs
))
{
failed
=
true
;
try
{
if
(
testInputStream
(
bs
))
{
failed
=
true
;
}
}
finally
{
bs
.
close
();
}
DataInputStream
dis
=
new
DataInputStream
(
new
FileInputStream
(
f
));
if
(
testInputStream
(
dis
))
{
failed
=
true
;
try
{
if
(
testInputStream
(
dis
))
{
failed
=
true
;
}
}
finally
{
dis
.
close
();
}
PushbackInputStream
pbis
=
new
PushbackInputStream
(
...
...
This diff is collapsed.
Click to expand it.
test/java/io/InputStream/ReadParams.java
浏览文件 @
d363c21d
...
...
@@ -137,6 +137,7 @@ public class ReadParams {
oos
.
writeInt
(
12345
);
oos
.
writeObject
(
"Today"
);
oos
.
writeObject
(
new
Integer
(
32
));
oos
.
close
();
ObjectInputStream
ois
=
new
ObjectInputStream
(
new
FileInputStream
(
fn
));
doTest
(
ois
);
doTest1
(
ois
);
...
...
This diff is collapsed.
Click to expand it.
test/java/io/InputStreamReader/GrowAfterEOF.java
浏览文件 @
d363c21d
...
...
@@ -33,29 +33,36 @@ public class GrowAfterEOF {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
File
input
=
new
File
(
"."
,
"TestEOFInput.txt"
);
RandomAccessFile
rf
=
new
RandomAccessFile
(
input
,
"rw"
);
BufferedReader
r
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
input
)));
try
{
BufferedReader
r
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
input
)));
try
{
// write something
rf
.
writeBytes
(
"a line"
);
// write something
rf
.
writeBytes
(
"a line"
);
// read till the end of file
while
(
r
.
readLine
()
!=
null
);
// read till the end of file
while
(
r
.
readLine
()
!=
null
);
// append to the end of the file
rf
.
seek
(
rf
.
length
());
rf
.
writeBytes
(
"new line"
);
// append to the end of the file
rf
.
seek
(
rf
.
length
());
rf
.
writeBytes
(
"new line"
);
// now try to read again
boolean
readMore
=
false
;
while
(
r
.
readLine
()
!=
null
)
{
readMore
=
true
;
}
if
(!
readMore
)
{
input
.
delete
();
throw
new
Exception
(
"Failed test: unable to read!"
);
}
else
{
input
.
delete
();
// now try to read again
boolean
readMore
=
false
;
while
(
r
.
readLine
()
!=
null
)
{
readMore
=
true
;
}
if
(!
readMore
)
{
input
.
delete
();
throw
new
Exception
(
"Failed test: unable to read!"
);
}
else
{
input
.
delete
();
}
}
finally
{
r
.
close
();
}
}
finally
{
rf
.
close
();
}
}
}
This diff is collapsed.
Click to expand it.
test/java/io/ObjectInputStream/ResolveProxyClass.java
浏览文件 @
d363c21d
...
...
@@ -79,7 +79,7 @@ public class ResolveProxyClass {
* code, and it should be the first loader on the stack when
* ObjectInputStream.resolveProxyClass gets executed.
*/
ClassLoader
expectedLoader
=
ClassLoader
.
getSystem
ClassLoader
();
ClassLoader
expectedLoader
=
ResolveProxyClass
.
class
.
get
ClassLoader
();
TestObjectInputStream
in
=
new
TestObjectInputStream
();
Class
proxyClass
=
in
.
resolveProxyClass
(
...
...
This diff is collapsed.
Click to expand it.
test/java/io/RandomAccessFile/EOF.java
浏览文件 @
d363c21d
...
...
@@ -35,12 +35,16 @@ public class EOF {
int
n
;
String
dir
=
System
.
getProperty
(
"test.src"
,
"."
);
RandomAccessFile
raf
=
new
RandomAccessFile
(
new
File
(
dir
,
"EOF.java"
),
"r"
);
for
(;;)
{
n
=
raf
.
read
(
buf
,
0
,
buf
.
length
);
if
(
n
<=
0
)
break
;
try
{
for
(;;)
{
n
=
raf
.
read
(
buf
,
0
,
buf
.
length
);
if
(
n
<=
0
)
break
;
}
if
(
n
!=
-
1
)
throw
new
RuntimeException
(
"Expected -1 for EOF, got "
+
n
);
}
finally
{
raf
.
close
();
}
if
(
n
!=
-
1
)
throw
new
RuntimeException
(
"Expected -1 for EOF, got "
+
n
);
}
}
This diff is collapsed.
Click to expand it.
test/java/io/RandomAccessFile/ParameterCheck.java
浏览文件 @
d363c21d
...
...
@@ -44,6 +44,7 @@ public class ParameterCheck {
private
static
void
doTest
(
String
method
)
throws
Exception
{
File
fn
=
new
File
(
"x.ParameterCheck"
);
RandomAccessFile
raf
=
null
;
try
{
byte
b
[]
=
new
byte
[
32
];
...
...
@@ -55,7 +56,7 @@ public class ParameterCheck {
fout
.
write
(
i
);
}
fout
.
close
();
RandomAccessFile
raf
=
new
RandomAccessFile
(
fn
,
"rw"
);
raf
=
new
RandomAccessFile
(
fn
,
"rw"
);
System
.
err
.
println
(
"-----------------------------"
+
"-----------------------------"
);
...
...
@@ -125,6 +126,8 @@ public class ParameterCheck {
System
.
err
.
println
(
"-----------------------------"
+
"-----------------------------"
);
}
finally
{
if
(
raf
!=
null
)
raf
.
close
();
fn
.
delete
();
}
...
...
This diff is collapsed.
Click to expand it.
test/java/io/RandomAccessFile/ReadLine.java
浏览文件 @
d363c21d
...
...
@@ -33,26 +33,30 @@ public class ReadLine {
public
static
void
main
(
String
args
[])
throws
Exception
{
File
fn
=
new
File
(
"x.ReadLine"
);
RandomAccessFile
raf
=
new
RandomAccessFile
(
fn
,
"rw"
);
String
line
;
int
ctr
=
1
;
String
expected
;
try
{
String
line
;
int
ctr
=
1
;
String
expected
;
raf
.
writeBytes
(
"ln1\rln2\r\nln3\nln4\rln5\r\nln6\n\rln8\r\rln10\n\nln12\r\r\nln14"
);
raf
.
seek
(
0
);
raf
.
writeBytes
(
"ln1\rln2\r\nln3\nln4\rln5\r\nln6\n\rln8\r\rln10\n\nln12\r\r\nln14"
);
raf
.
seek
(
0
);
while
((
line
=
raf
.
readLine
())
!=
null
)
{
if
((
ctr
==
7
)
||
(
ctr
==
9
)
||
(
ctr
==
11
)
||
(
ctr
==
13
))
{
expected
=
""
;
}
else
{
expected
=
"ln"
+
ctr
;
while
((
line
=
raf
.
readLine
())
!=
null
)
{
if
((
ctr
==
7
)
||
(
ctr
==
9
)
||
(
ctr
==
11
)
||
(
ctr
==
13
))
{
expected
=
""
;
}
else
{
expected
=
"ln"
+
ctr
;
}
if
(!
line
.
equals
(
expected
))
{
throw
new
Exception
(
"Expected \""
+
expected
+
"\""
+
", read \""
+
line
+
"\""
);
}
ctr
++;
}
if
(!
line
.
equals
(
expected
))
{
throw
new
Exception
(
"Expected \""
+
expected
+
"\""
+
", read \""
+
line
+
"\""
);
}
ctr
++;
}
finally
{
raf
.
close
();
}
System
.
err
.
println
(
"Successfully completed test!"
);
}
...
...
This diff is collapsed.
Click to expand it.
test/java/io/RandomAccessFile/Seek.java
浏览文件 @
d363c21d
...
...
@@ -44,6 +44,8 @@ public class Seek
throw
new
Exception
(
"Should have thrown an IOException when seek offset is < 0"
);
}
catch
(
IOException
e
)
{
}
finally
{
raf
.
close
();
}
}
}
This diff is collapsed.
Click to expand it.
test/java/io/RandomAccessFile/WriteBytesChars.java
浏览文件 @
d363c21d
...
...
@@ -37,8 +37,8 @@ public class WriteBytesChars {
byte
[]
b
=
new
byte
[
80
];
File
fn
=
new
File
(
"x.WriteBytesChars"
);
try
{
RandomAccessFile
raf
=
new
RandomAccessFile
(
fn
,
"rw"
);;
RandomAccessFile
raf
=
new
RandomAccessFile
(
fn
,
"rw"
);;
try
{
for
(
int
i
=
0
;
i
<
80
;
i
++)
{
buf
[
i
]
=
'a'
;
}
...
...
@@ -71,6 +71,7 @@ public class WriteBytesChars {
RuntimeException
(
"RandomAccessFile.writeChars, wrong result"
);
}
}
finally
{
raf
.
close
();
fn
.
delete
();
}
}
...
...
This diff is collapsed.
Click to expand it.
test/java/io/RandomAccessFile/WriteUTF.java
浏览文件 @
d363c21d
...
...
@@ -42,8 +42,8 @@ public class WriteUTF {
s
+=
s
;
System
.
err
.
println
(
"String length "
+
s
.
length
());
f
=
new
RandomAccessFile
(
fn
,
"rw"
);
try
{
f
=
new
RandomAccessFile
(
fn
,
"rw"
);
try
{
f
.
writeUTF
(
s
);
}
...
...
@@ -53,6 +53,7 @@ public class WriteUTF {
throw
new
RuntimeException
(
"UTFDataFormatException not thrown"
);
}
finally
{
f
.
close
();
fn
.
delete
();
}
...
...
This diff is collapsed.
Click to expand it.
test/java/io/RandomAccessFile/skipBytes/SkipBytes.java
浏览文件 @
d363c21d
...
...
@@ -96,14 +96,18 @@ public class SkipBytes{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
RandomAccessFile
raf
=
new
RandomAccessFile
(
"input.txt"
,
"rw"
);
int
length
=
(
int
)
raf
.
length
();
doTest
(
raf
,
0
,
2
*
length
);
doTest
(
raf
,
0
,
length
);
doTest
(
raf
,
0
,
length
/
2
);
doTest
(
raf
,
length
/
2
,
-
2
);
doTest
(
raf
,
length
,
0
);
doTest
(
raf
,
0
,
-
1
);
try
{
int
length
=
(
int
)
raf
.
length
();
doTest
(
raf
,
0
,
2
*
length
);
doTest
(
raf
,
0
,
length
);
doTest
(
raf
,
0
,
length
/
2
);
doTest
(
raf
,
length
/
2
,
-
2
);
doTest
(
raf
,
length
,
0
);
doTest
(
raf
,
0
,
-
1
);
}
finally
{
raf
.
close
();
}
}
...
...
This diff is collapsed.
Click to expand it.
test/java/io/Reader/Skip.java
浏览文件 @
d363c21d
...
...
@@ -35,12 +35,16 @@ public class Skip {
File
f
=
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"SkipInput.txt"
);
FileReader
fr
=
new
FileReader
(
f
);
long
nchars
=
8200
;
long
actual
=
fr
.
skip
(
nchars
);
try
{
long
nchars
=
8200
;
long
actual
=
fr
.
skip
(
nchars
);
if
(
actual
>
nchars
)
{
throw
new
Exception
(
"Should skip "
+
nchars
+
", but skipped "
+
actual
+
" chars"
);
if
(
actual
>
nchars
)
{
throw
new
Exception
(
"Should skip "
+
nchars
+
", but skipped "
+
actual
+
" chars"
);
}
}
finally
{
fr
.
close
();
}
}
}
This diff is collapsed.
Click to expand it.
test/java/io/Reader/SkipNegative.java
浏览文件 @
d363c21d
...
...
@@ -41,6 +41,8 @@ public class SkipNegative {
}
catch
(
IllegalArgumentException
e
){
// Negative argument caught
return
;
}
finally
{
fr
.
close
();
}
throw
new
Exception
(
"Skip should not accept negative values"
);
}
...
...
This diff is collapsed.
Click to expand it.
test/java/io/StreamTokenizer/Comment.java
浏览文件 @
d363c21d
...
...
@@ -41,40 +41,45 @@ public class Comment {
int
slashStarComment
=
4
;
for
(
int
i
=
0
;
i
<
8
;
i
++)
{
StreamTokenizer
st
=
new
StreamTokenizer
(
new
FileReader
(
f
));
FileReader
reader
=
new
FileReader
(
f
);
try
{
StreamTokenizer
st
=
new
StreamTokenizer
(
reader
);
/* decide the state of this run */
boolean
slashCommentFlag
=
((
i
&
slashIsCommentStart
)
!=
0
);
boolean
slashSlashCommentFlag
=
((
i
&
slashSlashComment
)
!=
0
);
boolean
slashStarCommentFlag
=
((
i
&
slashStarComment
)
!=
0
);
/* decide the state of this run */
boolean
slashCommentFlag
=
((
i
&
slashIsCommentStart
)
!=
0
);
boolean
slashSlashCommentFlag
=
((
i
&
slashSlashComment
)
!=
0
);
boolean
slashStarCommentFlag
=
((
i
&
slashStarComment
)
!=
0
);
/* set the initial state of the tokenizer */
if
(!
slashCommentFlag
)
{
st
.
ordinaryChar
(
'/'
);
}
st
.
slashSlashComments
(
slashSlashCommentFlag
);
st
.
slashStarComments
(
slashStarCommentFlag
);
/* set the initial state of the tokenizer */
if
(!
slashCommentFlag
)
{
st
.
ordinaryChar
(
'/'
);
}
st
.
slashSlashComments
(
slashSlashCommentFlag
);
st
.
slashStarComments
(
slashStarCommentFlag
);
/* now go throgh the input file */
while
(
st
.
nextToken
()
!=
StreamTokenizer
.
TT_EOF
)
{
String
token
=
st
.
sval
;
if
(
token
==
null
)
{
continue
;
}
else
{
if
((
token
.
compareTo
(
"Error1"
)
==
0
)
&&
slashStarCommentFlag
)
{
throw
new
Exception
(
"Failed to pass one line C comments!"
);
}
if
((
token
.
compareTo
(
"Error2"
)
==
0
)
&&
slashStarCommentFlag
)
{
throw
new
Exception
(
"Failed to pass multi line C comments!"
);
}
if
((
token
.
compareTo
(
"Error3"
)
==
0
)
&&
slashSlashCommentFlag
)
{
throw
new
Exception
(
"Failed to pass C++ comments!"
);
}
if
((
token
.
compareTo
(
"Error4"
)
==
0
)
&&
slashCommentFlag
)
{
throw
new
Exception
(
"Failed to pass / comments!"
);
/* now go throgh the input file */
while
(
st
.
nextToken
()
!=
StreamTokenizer
.
TT_EOF
)
{
String
token
=
st
.
sval
;
if
(
token
==
null
)
{
continue
;
}
else
{
if
((
token
.
compareTo
(
"Error1"
)
==
0
)
&&
slashStarCommentFlag
)
{
throw
new
Exception
(
"Failed to pass one line C comments!"
);
}
if
((
token
.
compareTo
(
"Error2"
)
==
0
)
&&
slashStarCommentFlag
)
{
throw
new
Exception
(
"Failed to pass multi line C comments!"
);
}
if
((
token
.
compareTo
(
"Error3"
)
==
0
)
&&
slashSlashCommentFlag
)
{
throw
new
Exception
(
"Failed to pass C++ comments!"
);
}
if
((
token
.
compareTo
(
"Error4"
)
==
0
)
&&
slashCommentFlag
)
{
throw
new
Exception
(
"Failed to pass / comments!"
);
}
}
}
}
finally
{
reader
.
close
();
}
}
}
...
...
This diff is collapsed.
Click to expand it.
test/java/io/readBytes/ReadBytesBounds.java
浏览文件 @
d363c21d
...
...
@@ -57,24 +57,28 @@ public class ReadBytesBounds {
}
public
static
void
main
(
String
argv
[])
throws
Throwable
{
byte
b
[]
=
new
byte
[
32
];
testRead
(-
1
,
-
1
,
false
);
testRead
(-
1
,
0
,
false
);
testRead
(
0
,
-
1
,
false
);
testRead
(
0
,
33
,
false
);
testRead
(
33
,
0
,
false
);
testRead
(
33
,
4
,
false
);
testRead
(
0
,
32
,
true
);
testRead
(
32
,
0
,
true
);
testRead
(
32
,
4
,
false
);
testRead
(
4
,
16
,
true
);
testRead
(
1
,
31
,
true
);
testRead
(
0
,
0
,
true
);
testRead
(
31
,
Integer
.
MAX_VALUE
,
false
);
testRead
(
0
,
Integer
.
MAX_VALUE
,
false
);
testRead
(-
1
,
Integer
.
MAX_VALUE
,
false
);
testRead
(-
4
,
Integer
.
MIN_VALUE
,
false
);
testRead
(
0
,
Integer
.
MIN_VALUE
,
false
);
try
{
testRead
(-
1
,
-
1
,
false
);
testRead
(-
1
,
0
,
false
);
testRead
(
0
,
-
1
,
false
);
testRead
(
0
,
33
,
false
);
testRead
(
33
,
0
,
false
);
testRead
(
33
,
4
,
false
);
testRead
(
0
,
32
,
true
);
testRead
(
32
,
0
,
true
);
testRead
(
32
,
4
,
false
);
testRead
(
4
,
16
,
true
);
testRead
(
1
,
31
,
true
);
testRead
(
0
,
0
,
true
);
testRead
(
31
,
Integer
.
MAX_VALUE
,
false
);
testRead
(
0
,
Integer
.
MAX_VALUE
,
false
);
testRead
(-
1
,
Integer
.
MAX_VALUE
,
false
);
testRead
(-
4
,
Integer
.
MIN_VALUE
,
false
);
testRead
(
0
,
Integer
.
MIN_VALUE
,
false
);
}
finally
{
fis
.
close
();
raf
.
close
();
}
}
static
void
testRead
(
int
off
,
int
len
,
boolean
expected
)
throws
Throwable
{
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
反馈
建议
客服
返回
顶部