Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4286fcb0
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看板
提交
4286fcb0
编写于
12月 09, 2014
作者:
V
vlivanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8066746: MHs.explicitCastArguments does incorrect type checks for VarargsCollector
Reviewed-by: jrose, psandoz
上级
54a226fd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
4 deletion
+19
-4
src/share/classes/java/lang/invoke/MethodHandles.java
src/share/classes/java/lang/invoke/MethodHandles.java
+1
-1
test/java/lang/invoke/ExplicitCastArgumentsTest.java
test/java/lang/invoke/ExplicitCastArgumentsTest.java
+18
-3
未找到文件。
src/share/classes/java/lang/invoke/MethodHandles.java
浏览文件 @
4286fcb0
...
...
@@ -2029,7 +2029,7 @@ return invoker;
MethodType
oldType
=
target
.
type
();
if
(
oldType
==
newType
)
return
target
;
if
(
oldType
.
explicitCastEquivalentToAsType
(
newType
))
{
return
target
.
asType
(
newType
);
return
target
.
as
FixedArity
().
as
Type
(
newType
);
}
return
MethodHandleImpl
.
makePairwiseConvert
(
target
,
newType
,
false
);
}
...
...
test/java/lang/invoke/ExplicitCastArgumentsTest.java
浏览文件 @
4286fcb0
...
...
@@ -32,21 +32,36 @@ import sun.invoke.util.Wrapper;
*/
public
class
ExplicitCastArgumentsTest
{
private
static
final
boolean
VERBOSE
=
Boolean
.
getBoolean
(
"verbose"
);
private
static
final
Class
<?>
THIS_CLASS
=
ExplicitCastArgumentsTest
.
class
;
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
testVarargsCollector
();
testRef2Prim
();
System
.
out
.
println
(
"TEST PASSED"
);
}
public
static
String
[]
f
(
String
...
args
)
{
return
args
;
}
public
static
void
testVarargsCollector
()
throws
Throwable
{
MethodType
mt
=
MethodType
.
methodType
(
String
[].
class
,
String
[].
class
);
MethodHandle
mh
=
MethodHandles
.
publicLookup
().
findStatic
(
THIS_CLASS
,
"f"
,
mt
);
mh
=
MethodHandles
.
explicitCastArguments
(
mh
,
MethodType
.
methodType
(
Object
.
class
,
Object
.
class
));
mh
.
invokeWithArguments
((
Object
)(
new
String
[]
{
"str1"
,
"str2"
}));
}
public
static
void
testRef2Prim
()
throws
Throwable
{
for
(
Wrapper
from
:
Wrapper
.
values
())
{
for
(
Wrapper
to
:
Wrapper
.
values
())
{
if
(
from
==
Wrapper
.
VOID
||
to
==
Wrapper
.
VOID
)
continue
;
testRef2Prim
(
from
,
to
);
testRef2Prim
(
from
,
to
);
}
}
System
.
out
.
println
(
"TEST PASSED"
);
}
public
static
void
testRef2Prim
(
Wrapper
from
,
Wrapper
to
)
throws
Throwable
{
// MHs.eCA javadoc:
// If T0 is a reference and T1 a primitive, and if the reference is null at runtime, a zero value is introduced.
test
(
from
.
wrapperType
(),
to
.
primitiveType
(),
null
,
false
);
test
(
from
.
wrapperType
(),
to
.
primitiveType
(),
null
,
false
);
}
public
static
void
test
(
Class
<?>
from
,
Class
<?>
to
,
Object
param
,
boolean
failureExpected
)
throws
Throwable
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录