Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
98fcbd8f
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
98fcbd8f
编写于
12月 18, 2014
作者:
A
acorn
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8065366: Better private method resolution
Reviewed-by: hseigel, lfoltan, coleenp, ahgross
上级
cfea8a33
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
8 deletion
+34
-8
src/share/vm/classfile/defaultMethods.cpp
src/share/vm/classfile/defaultMethods.cpp
+7
-2
src/share/vm/oops/klassVtable.cpp
src/share/vm/oops/klassVtable.cpp
+27
-6
未找到文件。
src/share/vm/classfile/defaultMethods.cpp
浏览文件 @
98fcbd8f
...
...
@@ -731,10 +731,12 @@ class FindMethodsByErasedSig : public HierarchyVisitor<FindMethodsByErasedSig> {
Method
*
m
=
iklass
->
find_method
(
_method_name
,
_method_signature
);
// private interface methods are not candidates for default methods
// invokespecial to private interface methods doesn't use default method logic
// private class methods are not candidates for default methods,
// private methods do not override default methods, so need to perform
// default method inheritance without including private methods
// The overpasses are your supertypes' errors, we do not include them
// future: take access controls into account for superclass methods
if
(
m
!=
NULL
&&
!
m
->
is_static
()
&&
!
m
->
is_overpass
()
&&
(
!
iklass
->
is_interface
()
||
m
->
is_public
()))
{
if
(
m
!=
NULL
&&
!
m
->
is_static
()
&&
!
m
->
is_overpass
()
&&
!
m
->
is_private
())
{
if
(
_family
==
NULL
)
{
_family
=
new
StatefulMethodFamily
();
}
...
...
@@ -745,6 +747,9 @@ class FindMethodsByErasedSig : public HierarchyVisitor<FindMethodsByErasedSig> {
}
else
{
// This is the rule that methods in classes "win" (bad word) over
// methods in interfaces. This works because of single inheritance
// private methods in classes do not "win", they will be found
// first on searching, but overriding for invokevirtual needs
// to find default method candidates for the same signature
_family
->
set_target_if_empty
(
m
);
}
}
...
...
src/share/vm/oops/klassVtable.cpp
浏览文件 @
98fcbd8f
...
...
@@ -401,13 +401,15 @@ bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle tar
// get super_klass for method_holder for the found method
InstanceKlass
*
super_klass
=
super_method
->
method_holder
();
if
(
is_default
// private methods are also never overridden
if
(
!
super_method
->
is_private
()
&&
(
is_default
||
((
super_klass
->
is_override
(
super_method
,
target_loader
,
target_classname
,
THREAD
))
||
((
klass
->
major_version
()
>=
VTABLE_TRANSITIVE_OVERRIDE_VERSION
)
&&
((
super_klass
=
find_transitive_override
(
super_klass
,
target_method
,
i
,
target_loader
,
target_classname
,
THREAD
))
!=
(
InstanceKlass
*
)
NULL
))))
!=
(
InstanceKlass
*
)
NULL
))))
)
{
// Package private methods always need a new entry to root their own
// overriding. They may also override other methods.
...
...
@@ -689,9 +691,15 @@ bool klassVtable::is_miranda_entry_at(int i) {
// check if a method is a miranda method, given a class's methods table,
// its default_method table and its super
// Miranda methods are calculated twice:
// first: before vtable size calculation: including abstract and default
// first: before vtable size calculation: including abstract and superinterface default
// We include potential default methods to give them space in the vtable.
// During the first run, the default_methods list is empty
// This is seen by default method creation
// Second: recalculated during vtable initialization: only abstract
// Second: recalculated during vtable initialization: only include abstract methods.
// During the second run, default_methods is set up, so concrete methods from
// superinterfaces with matching names/signatures to default_methods are already
// in the default_methods list and do not need to be appended to the vtable
// as mirandas
// This is seen by link resolution and selection.
// "miranda" means not static, not defined by this class.
// private methods in interfaces do not belong in the miranda list.
...
...
@@ -706,8 +714,9 @@ bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
}
Symbol
*
name
=
m
->
name
();
Symbol
*
signature
=
m
->
signature
();
Method
*
mo
;
if
(
InstanceKlass
::
find_instance_method
(
class_methods
,
name
,
signature
)
==
NULL
)
{
if
(
(
mo
=
InstanceKlass
::
find_instance_method
(
class_methods
,
name
,
signature
)
)
==
NULL
)
{
// did not find it in the method table of the current class
if
((
default_methods
==
NULL
)
||
InstanceKlass
::
find_method
(
default_methods
,
name
,
signature
)
==
NULL
)
{
...
...
@@ -716,7 +725,7 @@ bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
return
true
;
}
Method
*
mo
=
InstanceKlass
::
cast
(
super
)
->
lookup_method
(
name
,
signature
);
mo
=
InstanceKlass
::
cast
(
super
)
->
lookup_method
(
name
,
signature
);
while
(
mo
!=
NULL
&&
mo
->
access_flags
().
is_static
()
&&
mo
->
method_holder
()
!=
NULL
&&
mo
->
method_holder
()
->
super
()
!=
NULL
)
...
...
@@ -728,6 +737,18 @@ bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
return
true
;
}
}
}
else
{
// if the local class has a private method, the miranda will not
// override it, so a vtable slot is needed
if
(
mo
->
access_flags
().
is_private
())
{
// Second round, weed out any superinterface methods that turned
// into default methods, i.e. were concrete not abstract in the end
if
((
default_methods
==
NULL
)
||
InstanceKlass
::
find_method
(
default_methods
,
name
,
signature
)
==
NULL
)
{
return
true
;
}
}
}
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录