Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
752ecce2
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
752ecce2
编写于
3月 28, 2013
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8010511: Tests are creating files in /tmp
Reviewed-by: darcy
上级
4c38602c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
82 addition
and
32 deletion
+82
-32
test/tools/javac/T6558476.java
test/tools/javac/T6558476.java
+4
-3
test/tools/javac/T6900149.java
test/tools/javac/T6900149.java
+8
-2
test/tools/javac/diags/CheckExamples.java
test/tools/javac/diags/CheckExamples.java
+43
-2
test/tools/javac/diags/RunExamples.java
test/tools/javac/diags/RunExamples.java
+27
-25
未找到文件。
test/tools/javac/T6558476.java
浏览文件 @
752ecce2
/*
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
/*
/*
* @test
* @test
* @bug 6558476
* @summary com/sun/tools/javac/Main.compile don't release file handles on return
* @run main/othervm -Xmx512m -Xms512m T6558476
* @run main/othervm -Xmx512m -Xms512m T6558476
*/
*/
...
@@ -70,8 +72,7 @@ public class T6558476 {
...
@@ -70,8 +72,7 @@ public class T6558476 {
public
static
void
main
(
String
[]
args
)
throws
IOException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
File
javaHomeDir
=
new
File
(
System
.
getProperty
(
"java.home"
));
File
javaHomeDir
=
new
File
(
System
.
getProperty
(
"java.home"
));
File
tmpDir
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
));
File
outputDir
=
new
File
(
"outputDir"
+
new
Random
().
nextInt
(
65536
));
File
outputDir
=
new
File
(
tmpDir
,
"outputDir"
+
new
Random
().
nextInt
(
65536
));
outputDir
.
mkdir
();
outputDir
.
mkdir
();
outputDir
.
deleteOnExit
();
outputDir
.
deleteOnExit
();
...
...
test/tools/javac/T6900149.java
浏览文件 @
752ecce2
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -39,7 +39,7 @@ public class T6900149 {
...
@@ -39,7 +39,7 @@ public class T6900149 {
JavaCompiler
compiler
=
ToolProvider
.
getSystemJavaCompiler
();
JavaCompiler
compiler
=
ToolProvider
.
getSystemJavaCompiler
();
StandardJavaFileManager
fm
=
StandardJavaFileManager
fm
=
compiler
.
getStandardFileManager
(
null
,
null
,
null
);
compiler
.
getStandardFileManager
(
null
,
null
,
null
);
File
emptyFile
=
File
.
createTempFile
(
"Empty"
,
"
.java"
);
File
emptyFile
=
createTempFile
(
"Empty
.java"
);
File
[]
files
=
new
File
[]
{
emptyFile
,
emptyFile
};
File
[]
files
=
new
File
[]
{
emptyFile
,
emptyFile
};
CompilationTask
task
=
compiler
.
getTask
(
null
,
fm
,
diag
,
CompilationTask
task
=
compiler
.
getTask
(
null
,
fm
,
diag
,
null
,
null
,
fm
.
getJavaFileObjects
(
files
));
null
,
null
,
fm
.
getJavaFileObjects
(
files
));
...
@@ -47,4 +47,10 @@ public class T6900149 {
...
@@ -47,4 +47,10 @@ public class T6900149 {
throw
new
AssertionError
(
"compilation failed"
);
throw
new
AssertionError
(
"compilation failed"
);
}
}
}
}
private
static
File
createTempFile
(
String
path
)
throws
IOException
{
File
f
=
new
File
(
path
);
try
(
FileWriter
out
=
new
FileWriter
(
f
))
{
}
return
f
;
}
}
}
test/tools/javac/diags/CheckExamples.java
浏览文件 @
752ecce2
/*
/*
* Copyright (c) 2010, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -34,6 +34,8 @@
...
@@ -34,6 +34,8 @@
*/
*/
import
java.io.*
;
import
java.io.*
;
import
java.nio.file.*
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.util.*
;
import
java.util.*
;
/**
/**
...
@@ -53,7 +55,27 @@ public class CheckExamples {
...
@@ -53,7 +55,27 @@ public class CheckExamples {
* Standard entry point.
* Standard entry point.
*/
*/
public
static
void
main
(
String
...
args
)
throws
Exception
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
CheckExamples
().
run
();
boolean
jtreg
=
(
System
.
getProperty
(
"test.src"
)
!=
null
);
Path
tmpDir
;
boolean
deleteOnExit
;
if
(
jtreg
)
{
// use standard jtreg scratch directory: the current directory
tmpDir
=
Paths
.
get
(
System
.
getProperty
(
"user.dir"
));
deleteOnExit
=
false
;
}
else
{
tmpDir
=
Files
.
createTempDirectory
(
Paths
.
get
(
System
.
getProperty
(
"java.io.tmpdir"
)),
CheckExamples
.
class
.
getName
());
deleteOnExit
=
true
;
}
Example
.
setTempDir
(
tmpDir
.
toFile
());
try
{
new
CheckExamples
().
run
();
}
finally
{
if
(
deleteOnExit
)
{
clean
(
tmpDir
);
}
}
}
}
/**
/**
...
@@ -190,6 +212,25 @@ public class CheckExamples {
...
@@ -190,6 +212,25 @@ public class CheckExamples {
int
errors
;
int
errors
;
/**
* Clean the contents of a directory.
*/
static
void
clean
(
Path
dir
)
throws
IOException
{
Files
.
walkFileTree
(
dir
,
new
SimpleFileVisitor
<
Path
>()
{
@Override
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
throws
IOException
{
Files
.
delete
(
file
);
return
super
.
visitFile
(
file
,
attrs
);
}
@Override
public
FileVisitResult
postVisitDirectory
(
Path
dir
,
IOException
exc
)
throws
IOException
{
if
(
exc
==
null
)
Files
.
delete
(
dir
);
return
super
.
postVisitDirectory
(
dir
,
exc
);
}
});
}
static
class
Counts
{
static
class
Counts
{
static
String
[]
prefixes
=
{
static
String
[]
prefixes
=
{
"compiler.err."
,
"compiler.err."
,
...
...
test/tools/javac/diags/RunExamples.java
浏览文件 @
752ecce2
/*
/*
* Copyright (c) 2010, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -33,7 +33,8 @@
...
@@ -33,7 +33,8 @@
*/
*/
import
java.io.*
;
import
java.io.*
;
import
java.text.SimpleDateFormat
;
import
java.nio.file.*
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.util.*
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
...
@@ -56,16 +57,18 @@ import java.util.regex.Pattern;
...
@@ -56,16 +57,18 @@ import java.util.regex.Pattern;
public
class
RunExamples
{
public
class
RunExamples
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
jtreg
=
(
System
.
getProperty
(
"test.src"
)
!=
null
);
jtreg
=
(
System
.
getProperty
(
"test.src"
)
!=
null
);
File
tmpDir
;
Path
tmpDir
;
boolean
deleteOnExit
;
if
(
jtreg
)
{
if
(
jtreg
)
{
// use standard jtreg scratch directory: the current directory
// use standard jtreg scratch directory: the current directory
tmpDir
=
new
File
(
System
.
getProperty
(
"user.dir"
));
tmpDir
=
Paths
.
get
(
System
.
getProperty
(
"user.dir"
));
deleteOnExit
=
false
;
}
else
{
}
else
{
tmpDir
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
),
tmpDir
=
Files
.
createTempDirectory
(
Paths
.
get
(
System
.
getProperty
(
"java.io.tmpdir"
)
),
RunExamples
.
class
.
getName
()
RunExamples
.
class
.
getName
()
);
+
(
new
SimpleDateFormat
(
"yyMMddHHmmss"
)).
format
(
new
Date
()))
;
deleteOnExit
=
true
;
}
}
Example
.
setTempDir
(
tmpDir
);
Example
.
setTempDir
(
tmpDir
.
toFile
()
);
RunExamples
r
=
new
RunExamples
();
RunExamples
r
=
new
RunExamples
();
...
@@ -73,15 +76,8 @@ public class RunExamples {
...
@@ -73,15 +76,8 @@ public class RunExamples {
if
(
r
.
run
(
args
))
if
(
r
.
run
(
args
))
return
;
return
;
}
finally
{
}
finally
{
/* VERY IMPORTANT NOTE. In jtreg mode, tmpDir is set to the
if
(
deleteOnExit
)
{
* jtreg scratch directory, which is the current directory.
clean
(
tmpDir
);
* In case someone is faking jtreg mode, make sure to only
* clean tmpDir when it is reasonable to do so.
*/
if
(
tmpDir
.
isDirectory
()
&&
tmpDir
.
getName
().
startsWith
(
RunExamples
.
class
.
getName
()))
{
if
(
clean
(
tmpDir
))
tmpDir
.
delete
();
}
}
}
}
...
@@ -203,14 +199,20 @@ public class RunExamples {
...
@@ -203,14 +199,20 @@ public class RunExamples {
/**
/**
* Clean the contents of a directory.
* Clean the contents of a directory.
*/
*/
static
boolean
clean
(
File
dir
)
{
static
void
clean
(
Path
dir
)
throws
IOException
{
boolean
ok
=
true
;
Files
.
walkFileTree
(
dir
,
new
SimpleFileVisitor
<
Path
>()
{
for
(
File
f:
dir
.
listFiles
())
{
@Override
if
(
f
.
isDirectory
())
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
throws
IOException
{
ok
&=
clean
(
f
);
Files
.
delete
(
file
);
ok
&=
f
.
delete
();
return
super
.
visitFile
(
file
,
attrs
);
}
}
return
ok
;
@Override
public
FileVisitResult
postVisitDirectory
(
Path
dir
,
IOException
exc
)
throws
IOException
{
if
(
exc
==
null
)
Files
.
delete
(
dir
);
return
super
.
postVisitDirectory
(
dir
,
exc
);
}
});
}
}
static
abstract
class
Runner
{
static
abstract
class
Runner
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录