Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f63c3865
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f63c3865
编写于
3月 08, 2013
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8006000: TEST_BUG: java/lang/invoke/lambda/LambdaAccessControlTest.java fails intermittently
Reviewed-by: chegar
上级
2e0ee4de
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
173 addition
and
147 deletion
+173
-147
test/java/lang/invoke/lambda/LUtils.java
test/java/lang/invoke/lambda/LUtils.java
+171
-0
test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java
...ng/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java
+1
-146
test/java/lang/invoke/lambda/LambdaAccessControlTest.java
test/java/lang/invoke/lambda/LambdaAccessControlTest.java
+1
-1
未找到文件。
test/java/lang/invoke/lambda/LUtils.java
0 → 100644
浏览文件 @
f63c3865
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.nio.charset.Charset
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/*
* support infrastructure to invoke a java class from the command line
*/
class
LUtils
{
static
final
sun
.
tools
.
jar
.
Main
jarTool
=
new
sun
.
tools
.
jar
.
Main
(
System
.
out
,
System
.
err
,
"jar-tool"
);
static
final
com
.
sun
.
tools
.
javac
.
Main
javac
=
new
com
.
sun
.
tools
.
javac
.
Main
();
static
final
File
cwd
=
new
File
(
"."
).
getAbsoluteFile
();
static
final
String
JAVAHOME
=
System
.
getProperty
(
"java.home"
);
static
final
boolean
isWindows
=
System
.
getProperty
(
"os.name"
,
"unknown"
).
startsWith
(
"Windows"
);
//static final boolean isSDK = JAVAHOME.endsWith("jre");
static
final
File
JAVA_BIN_FILE
=
new
File
(
JAVAHOME
,
"bin"
);
static
final
File
JAVA_CMD
=
new
File
(
JAVA_BIN_FILE
,
isWindows
?
"java.exe"
:
"java"
);
protected
LUtils
()
{
}
public
static
void
compile
(
String
...
args
)
{
if
(
javac
.
compile
(
args
)
!=
0
)
{
throw
new
RuntimeException
(
"compilation fails"
);
}
}
static
void
createFile
(
File
outFile
,
List
<
String
>
content
)
{
try
{
Files
.
write
(
outFile
.
getAbsoluteFile
().
toPath
(),
content
,
Charset
.
defaultCharset
());
}
catch
(
IOException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
static
File
getClassFile
(
File
javaFile
)
{
return
javaFile
.
getName
().
endsWith
(
".java"
)
?
new
File
(
javaFile
.
getName
().
replace
(
".java"
,
".class"
))
:
null
;
}
static
String
getSimpleName
(
File
inFile
)
{
String
fname
=
inFile
.
getName
();
return
fname
.
substring
(
0
,
fname
.
indexOf
(
"."
));
}
static
TestResult
doExec
(
String
...
cmds
)
{
return
doExec
(
null
,
null
,
cmds
);
}
/*
* A method which executes a java cmd and returns the results in a container
*/
static
TestResult
doExec
(
Map
<
String
,
String
>
envToSet
,
java
.
util
.
Set
<
String
>
envToRemove
,
String
...
cmds
)
{
String
cmdStr
=
""
;
for
(
String
x
:
cmds
)
{
cmdStr
=
cmdStr
.
concat
(
x
+
" "
);
}
ProcessBuilder
pb
=
new
ProcessBuilder
(
cmds
);
Map
<
String
,
String
>
env
=
pb
.
environment
();
if
(
envToRemove
!=
null
)
{
for
(
String
key
:
envToRemove
)
{
env
.
remove
(
key
);
}
}
if
(
envToSet
!=
null
)
{
env
.
putAll
(
envToSet
);
}
BufferedReader
rdr
=
null
;
try
{
List
<
String
>
outputList
=
new
ArrayList
<>();
pb
.
redirectErrorStream
(
true
);
Process
p
=
pb
.
start
();
rdr
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
()));
String
in
=
rdr
.
readLine
();
while
(
in
!=
null
)
{
outputList
.
add
(
in
);
in
=
rdr
.
readLine
();
}
p
.
waitFor
();
p
.
destroy
();
return
new
TestResult
(
cmdStr
,
p
.
exitValue
(),
outputList
,
env
,
new
Throwable
(
"current stack of the test"
));
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
throw
new
RuntimeException
(
ex
.
getMessage
());
}
}
static
class
TestResult
{
String
cmd
;
int
exitValue
;
List
<
String
>
testOutput
;
Map
<
String
,
String
>
env
;
Throwable
t
;
public
TestResult
(
String
str
,
int
rv
,
List
<
String
>
oList
,
Map
<
String
,
String
>
env
,
Throwable
t
)
{
cmd
=
str
;
exitValue
=
rv
;
testOutput
=
oList
;
this
.
env
=
env
;
this
.
t
=
t
;
}
void
assertZero
(
String
message
)
{
if
(
exitValue
!=
0
)
{
System
.
err
.
println
(
this
);
throw
new
RuntimeException
(
message
);
}
}
@Override
public
String
toString
()
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
status
=
new
PrintWriter
(
sw
);
status
.
println
(
"Cmd: "
+
cmd
);
status
.
println
(
"Return code: "
+
exitValue
);
status
.
println
(
"Environment variable:"
);
for
(
String
x
:
env
.
keySet
())
{
status
.
println
(
"\t"
+
x
+
"="
+
env
.
get
(
x
));
}
status
.
println
(
"Output:"
);
for
(
String
x
:
testOutput
)
{
status
.
println
(
"\t"
+
x
);
}
status
.
println
(
"Exception:"
);
status
.
println
(
t
.
getMessage
());
t
.
printStackTrace
(
status
);
return
sw
.
getBuffer
().
toString
();
}
}
}
test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java
浏览文件 @
f63c3865
...
...
@@ -26,20 +26,12 @@
* @bug 8003881
* @summary tests DoPrivileged action (implemented as lambda expressions) by
* inserting them into the BootClassPath.
* @compile -XDignore.symbol.file LambdaAccessControlDoPrivilegedTest.java
* @compile -XDignore.symbol.file LambdaAccessControlDoPrivilegedTest.java
LUtils.java
* @run main/othervm LambdaAccessControlDoPrivilegedTest
*/
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.nio.charset.Charset
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
LambdaAccessControlDoPrivilegedTest
extends
LUtils
{
public
static
void
main
(
String
...
args
)
{
...
...
@@ -87,140 +79,3 @@ public class LambdaAccessControlDoPrivilegedTest extends LUtils {
jarFile
.
delete
();
}
}
/*
* support infrastructure to invoke a java class from the command line
*/
class
LUtils
{
static
final
sun
.
tools
.
jar
.
Main
jarTool
=
new
sun
.
tools
.
jar
.
Main
(
System
.
out
,
System
.
err
,
"jar-tool"
);
static
final
com
.
sun
.
tools
.
javac
.
Main
javac
=
new
com
.
sun
.
tools
.
javac
.
Main
();
static
final
File
cwd
=
new
File
(
"."
).
getAbsoluteFile
();
static
final
String
JAVAHOME
=
System
.
getProperty
(
"java.home"
);
static
final
boolean
isWindows
=
System
.
getProperty
(
"os.name"
,
"unknown"
).
startsWith
(
"Windows"
);
//static final boolean isSDK = JAVAHOME.endsWith("jre");
static
final
File
JAVA_BIN_FILE
=
new
File
(
JAVAHOME
,
"bin"
);
static
final
File
JAVA_CMD
=
new
File
(
JAVA_BIN_FILE
,
isWindows
?
"java.exe"
:
"java"
);
protected
LUtils
()
{
}
public
static
void
compile
(
String
...
args
)
{
if
(
javac
.
compile
(
args
)
!=
0
)
{
throw
new
RuntimeException
(
"compilation fails"
);
}
}
static
void
createFile
(
File
outFile
,
List
<
String
>
content
)
{
try
{
Files
.
write
(
outFile
.
getAbsoluteFile
().
toPath
(),
content
,
Charset
.
defaultCharset
());
}
catch
(
IOException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
static
File
getClassFile
(
File
javaFile
)
{
return
javaFile
.
getName
().
endsWith
(
".java"
)
?
new
File
(
javaFile
.
getName
().
replace
(
".java"
,
".class"
))
:
null
;
}
static
String
getSimpleName
(
File
inFile
)
{
String
fname
=
inFile
.
getName
();
return
fname
.
substring
(
0
,
fname
.
indexOf
(
"."
));
}
static
TestResult
doExec
(
String
...
cmds
)
{
return
doExec
(
null
,
null
,
cmds
);
}
/*
* A method which executes a java cmd and returns the results in a container
*/
static
TestResult
doExec
(
Map
<
String
,
String
>
envToSet
,
java
.
util
.
Set
<
String
>
envToRemove
,
String
...
cmds
)
{
String
cmdStr
=
""
;
for
(
String
x
:
cmds
)
{
cmdStr
=
cmdStr
.
concat
(
x
+
" "
);
}
ProcessBuilder
pb
=
new
ProcessBuilder
(
cmds
);
Map
<
String
,
String
>
env
=
pb
.
environment
();
if
(
envToRemove
!=
null
)
{
for
(
String
key
:
envToRemove
)
{
env
.
remove
(
key
);
}
}
if
(
envToSet
!=
null
)
{
env
.
putAll
(
envToSet
);
}
BufferedReader
rdr
=
null
;
try
{
List
<
String
>
outputList
=
new
ArrayList
<>();
pb
.
redirectErrorStream
(
true
);
Process
p
=
pb
.
start
();
rdr
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
()));
String
in
=
rdr
.
readLine
();
while
(
in
!=
null
)
{
outputList
.
add
(
in
);
in
=
rdr
.
readLine
();
}
p
.
waitFor
();
p
.
destroy
();
return
new
TestResult
(
cmdStr
,
p
.
exitValue
(),
outputList
,
env
,
new
Throwable
(
"current stack of the test"
));
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
throw
new
RuntimeException
(
ex
.
getMessage
());
}
}
static
class
TestResult
{
String
cmd
;
int
exitValue
;
List
<
String
>
testOutput
;
Map
<
String
,
String
>
env
;
Throwable
t
;
public
TestResult
(
String
str
,
int
rv
,
List
<
String
>
oList
,
Map
<
String
,
String
>
env
,
Throwable
t
)
{
cmd
=
str
;
exitValue
=
rv
;
testOutput
=
oList
;
this
.
env
=
env
;
this
.
t
=
t
;
}
void
assertZero
(
String
message
)
{
if
(
exitValue
!=
0
)
{
System
.
err
.
println
(
this
);
throw
new
RuntimeException
(
message
);
}
}
@Override
public
String
toString
()
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
status
=
new
PrintWriter
(
sw
);
status
.
println
(
"Cmd: "
+
cmd
);
status
.
println
(
"Return code: "
+
exitValue
);
status
.
println
(
"Environment variable:"
);
for
(
String
x
:
env
.
keySet
())
{
status
.
println
(
"\t"
+
x
+
"="
+
env
.
get
(
x
));
}
status
.
println
(
"Output:"
);
for
(
String
x
:
testOutput
)
{
status
.
println
(
"\t"
+
x
);
}
status
.
println
(
"Exception:"
);
status
.
println
(
t
.
getMessage
());
t
.
printStackTrace
(
status
);
return
sw
.
getBuffer
().
toString
();
}
}
}
test/java/lang/invoke/lambda/LambdaAccessControlTest.java
浏览文件 @
f63c3865
...
...
@@ -25,7 +25,7 @@
* @test
* @bug 8003881
* @summary tests Lambda expression with a a security manager at top level
* @compile -XDignore.symbol.file LambdaAccessControlTest.java
* @compile -XDignore.symbol.file LambdaAccessControlTest.java
LUtils.java
*
* @run main/othervm LambdaAccessControlTest
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录