Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
031a5ed1
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看板
提交
031a5ed1
编写于
1月 24, 2013
作者:
M
mchung
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8004937: Improve proxy construction
Reviewed-by: jrose, ahgross
上级
61126748
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
6 deletion
+21
-6
src/share/classes/java/lang/invoke/MethodHandleNatives.java
src/share/classes/java/lang/invoke/MethodHandleNatives.java
+2
-0
src/share/classes/java/lang/invoke/MethodHandleProxies.java
src/share/classes/java/lang/invoke/MethodHandleProxies.java
+19
-6
未找到文件。
src/share/classes/java/lang/invoke/MethodHandleNatives.java
浏览文件 @
031a5ed1
...
@@ -476,6 +476,8 @@ class MethodHandleNatives {
...
@@ -476,6 +476,8 @@ class MethodHandleNatives {
case
"getProxyClass"
:
case
"getProxyClass"
:
case
"newProxyInstance"
:
case
"newProxyInstance"
:
return
defc
==
java
.
lang
.
reflect
.
Proxy
.
class
;
return
defc
==
java
.
lang
.
reflect
.
Proxy
.
class
;
case
"asInterfaceInstance"
:
return
defc
==
java
.
lang
.
invoke
.
MethodHandleProxies
.
class
;
case
"getBundle"
:
case
"getBundle"
:
case
"clearCache"
:
case
"clearCache"
:
return
defc
==
java
.
util
.
ResourceBundle
.
class
;
return
defc
==
java
.
util
.
ResourceBundle
.
class
;
...
...
src/share/classes/java/lang/invoke/MethodHandleProxies.java
浏览文件 @
031a5ed1
...
@@ -141,12 +141,15 @@ public class MethodHandleProxies {
...
@@ -141,12 +141,15 @@ public class MethodHandleProxies {
<
T
>
T
asInterfaceInstance
(
final
Class
<
T
>
intfc
,
final
MethodHandle
target
)
{
<
T
>
T
asInterfaceInstance
(
final
Class
<
T
>
intfc
,
final
MethodHandle
target
)
{
if
(!
intfc
.
isInterface
()
||
!
Modifier
.
isPublic
(
intfc
.
getModifiers
()))
if
(!
intfc
.
isInterface
()
||
!
Modifier
.
isPublic
(
intfc
.
getModifiers
()))
throw
new
IllegalArgumentException
(
"not a public interface: "
+
intfc
.
getName
());
throw
new
IllegalArgumentException
(
"not a public interface: "
+
intfc
.
getName
());
SecurityManager
smgr
=
System
.
getSecurityManager
()
;
final
MethodHandle
mh
;
if
(
smgr
!=
null
)
{
if
(
System
.
getSecurityManager
()
!=
null
)
{
final
int
CALLER_FRAME
=
2
;
// 0: Reflection, 1: asInterfaceInstance, 2: caller
final
int
CALLER_FRAME
=
2
;
// 0: Reflection, 1: asInterfaceInstance, 2: caller
final
Class
<?>
caller
=
Reflection
.
getCallerClass
(
CALLER_FRAME
);
final
Class
<?>
caller
=
Reflection
.
getCallerClass
(
CALLER_FRAME
);
final
ClassLoader
ccl
=
caller
.
getClassLoader
()
;
final
ClassLoader
ccl
=
caller
!=
null
?
caller
.
getClassLoader
()
:
null
;
ReflectUtil
.
checkProxyPackageAccess
(
ccl
,
intfc
);
ReflectUtil
.
checkProxyPackageAccess
(
ccl
,
intfc
);
mh
=
ccl
!=
null
?
bindCaller
(
target
,
caller
)
:
target
;
}
else
{
mh
=
target
;
}
}
ClassLoader
proxyLoader
=
intfc
.
getClassLoader
();
ClassLoader
proxyLoader
=
intfc
.
getClassLoader
();
if
(
proxyLoader
==
null
)
{
if
(
proxyLoader
==
null
)
{
...
@@ -160,7 +163,7 @@ public class MethodHandleProxies {
...
@@ -160,7 +163,7 @@ public class MethodHandleProxies {
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++)
{
Method
sm
=
methods
[
i
];
Method
sm
=
methods
[
i
];
MethodType
smMT
=
MethodType
.
methodType
(
sm
.
getReturnType
(),
sm
.
getParameterTypes
());
MethodType
smMT
=
MethodType
.
methodType
(
sm
.
getReturnType
(),
sm
.
getParameterTypes
());
MethodHandle
checkTarget
=
target
.
asType
(
smMT
);
// make throw WMT
MethodHandle
checkTarget
=
mh
.
asType
(
smMT
);
// make throw WMT
checkTarget
=
checkTarget
.
asType
(
checkTarget
.
type
().
changeReturnType
(
Object
.
class
));
checkTarget
=
checkTarget
.
asType
(
checkTarget
.
type
().
changeReturnType
(
Object
.
class
));
vaTargets
[
i
]
=
checkTarget
.
asSpreader
(
Object
[].
class
,
smMT
.
parameterCount
());
vaTargets
[
i
]
=
checkTarget
.
asSpreader
(
Object
[].
class
,
smMT
.
parameterCount
());
}
}
...
@@ -183,8 +186,8 @@ public class MethodHandleProxies {
...
@@ -183,8 +186,8 @@ public class MethodHandleProxies {
}
}
};
};
Object
proxy
;
final
Object
proxy
;
if
(
smgr
!=
null
)
{
if
(
System
.
getSecurityManager
()
!=
null
)
{
// sun.invoke.WrapperInstance is a restricted interface not accessible
// sun.invoke.WrapperInstance is a restricted interface not accessible
// by any non-null class loader.
// by any non-null class loader.
final
ClassLoader
loader
=
proxyLoader
;
final
ClassLoader
loader
=
proxyLoader
;
...
@@ -204,6 +207,16 @@ public class MethodHandleProxies {
...
@@ -204,6 +207,16 @@ public class MethodHandleProxies {
return
intfc
.
cast
(
proxy
);
return
intfc
.
cast
(
proxy
);
}
}
private
static
MethodHandle
bindCaller
(
MethodHandle
target
,
Class
<?>
hostClass
)
{
MethodHandle
cbmh
=
MethodHandleImpl
.
bindCaller
(
target
,
hostClass
);
if
(
target
.
isVarargsCollector
())
{
MethodType
type
=
cbmh
.
type
();
int
arity
=
type
.
parameterCount
();
return
cbmh
.
asVarargsCollector
(
type
.
parameterType
(
arity
-
1
));
}
return
cbmh
;
}
/**
/**
* Determines if the given object was produced by a call to {@link #asInterfaceInstance asInterfaceInstance}.
* Determines if the given object was produced by a call to {@link #asInterfaceInstance asInterfaceInstance}.
* @param x any reference
* @param x any reference
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录