Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
bceab689
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bceab689
编写于
3月 24, 2016
作者:
P
psandoz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8149644: Integrate VarHandles
Reviewed-by: mcimadamore, forax
上级
38a7f975
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
50 addition
and
34 deletion
+50
-34
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java
...mpiler/share/classes/com/sun/tools/javac/code/Symtab.java
+2
-0
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java
...ompiler/share/classes/com/sun/tools/javac/code/Types.java
+7
-6
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java
...ompiler/share/classes/com/sun/tools/javac/comp/Infer.java
+31
-24
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
...piler/share/classes/com/sun/tools/javac/comp/Resolve.java
+10
-4
未找到文件。
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java
浏览文件 @
bceab689
...
...
@@ -151,6 +151,7 @@ public class Symtab {
public
final
Type
cloneableType
;
public
final
Type
serializableType
;
public
final
Type
serializedLambdaType
;
public
final
Type
varHandleType
;
public
final
Type
methodHandleType
;
public
final
Type
methodHandleLookupType
;
public
final
Type
methodTypeType
;
...
...
@@ -419,6 +420,7 @@ public class Symtab {
throwableType
=
enterClass
(
"java.lang.Throwable"
);
serializableType
=
enterClass
(
"java.io.Serializable"
);
serializedLambdaType
=
enterClass
(
"java.lang.invoke.SerializedLambda"
);
varHandleType
=
enterClass
(
"java.lang.invoke.VarHandle"
);
methodHandleType
=
enterClass
(
"java.lang.invoke.MethodHandle"
);
methodHandleLookupType
=
enterClass
(
"java.lang.invoke.MethodHandles$Lookup"
);
methodTypeType
=
enterClass
(
"java.lang.invoke.MethodType"
);
...
...
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java
浏览文件 @
bceab689
...
...
@@ -1062,18 +1062,19 @@ public class Types {
}
/**
* A polymorphic signature method (JLS 15.12.3) is a method that
* (i) is declared in the java.lang.invoke.MethodHandle class, (ii) takes
* a single variable arity parameter (iii) whose declared type is Object[],
* (iv) has a return type of Object and (v) is native.
* A polymorphic signature method (JLS 15.12.3) is a method that
* (i) is declared in the java.lang.invoke.MethodHandle/VarHandle classes;
* (ii) takes a single variable arity parameter;
* (iii) whose declared type is Object[];
* (iv) has any return type, Object signifying a polymorphic return type; and
* (v) is native.
*/
public
boolean
isSignaturePolymorphic
(
MethodSymbol
msym
)
{
List
<
Type
>
argtypes
=
msym
.
type
.
getParameterTypes
();
return
(
msym
.
flags_field
&
NATIVE
)
!=
0
&&
msym
.
owner
==
syms
.
methodHandleType
.
tsym
&&
(
msym
.
owner
==
syms
.
methodHandleType
.
tsym
||
msym
.
owner
==
syms
.
varHandleType
.
tsym
)
&&
argtypes
.
tail
.
tail
==
null
&&
argtypes
.
head
.
hasTag
(
TypeTag
.
ARRAY
)
&&
msym
.
type
.
getReturnType
().
tsym
==
syms
.
objectType
.
tsym
&&
((
ArrayType
)
argtypes
.
head
).
elemtype
.
tsym
==
syms
.
objectType
.
tsym
;
}
...
...
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java
浏览文件 @
bceab689
...
...
@@ -560,30 +560,37 @@ public class Infer {
List
<
Type
>
argtypes
)
{
final
Type
restype
;
//The return type for a polymorphic signature call is computed from
//the enclosing tree E, as follows: if E is a cast, then use the
//target type of the cast expression as a return type; if E is an
//expression statement, the return type is 'void' - otherwise the
//return type is simply 'Object'. A correctness check ensures that
//env.next refers to the lexically enclosing environment in which
//the polymorphic signature call environment is nested.
switch
(
env
.
next
.
tree
.
getTag
())
{
case
TYPECAST:
JCTypeCast
castTree
=
(
JCTypeCast
)
env
.
next
.
tree
;
restype
=
(
TreeInfo
.
skipParens
(
castTree
.
expr
)
==
env
.
tree
)
?
castTree
.
clazz
.
type
:
syms
.
objectType
;
break
;
case
EXEC:
JCTree
.
JCExpressionStatement
execTree
=
(
JCTree
.
JCExpressionStatement
)
env
.
next
.
tree
;
restype
=
(
TreeInfo
.
skipParens
(
execTree
.
expr
)
==
env
.
tree
)
?
syms
.
voidType
:
syms
.
objectType
;
break
;
default
:
restype
=
syms
.
objectType
;
if
(
spMethod
==
null
||
types
.
isSameType
(
spMethod
.
getReturnType
(),
syms
.
objectType
,
true
))
{
// The return type of the polymorphic signature is polymorphic,
// and is computed from the enclosing tree E, as follows:
// if E is a cast, then use the target type of the cast expression
// as a return type; if E is an expression statement, the return
// type is 'void'; otherwise
// the return type is simply 'Object'. A correctness check ensures
// that env.next refers to the lexically enclosing environment in
// which the polymorphic signature call environment is nested.
switch
(
env
.
next
.
tree
.
getTag
())
{
case
TYPECAST:
JCTypeCast
castTree
=
(
JCTypeCast
)
env
.
next
.
tree
;
restype
=
(
TreeInfo
.
skipParens
(
castTree
.
expr
)
==
env
.
tree
)
?
castTree
.
clazz
.
type
:
syms
.
objectType
;
break
;
case
EXEC:
JCTree
.
JCExpressionStatement
execTree
=
(
JCTree
.
JCExpressionStatement
)
env
.
next
.
tree
;
restype
=
(
TreeInfo
.
skipParens
(
execTree
.
expr
)
==
env
.
tree
)
?
syms
.
voidType
:
syms
.
objectType
;
break
;
default
:
restype
=
syms
.
objectType
;
}
}
else
{
// The return type of the polymorphic signature is fixed
// (not polymorphic)
restype
=
spMethod
.
getReturnType
();
}
List
<
Type
>
paramtypes
=
argtypes
.
map
(
new
ImplicitArgType
(
spMethod
,
resolveContext
.
step
));
...
...
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
浏览文件 @
bceab689
...
...
@@ -2461,13 +2461,19 @@ public class Resolve {
Type
mtype
=
infer
.
instantiatePolymorphicSignatureInstance
(
env
,
(
MethodSymbol
)
spMethod
,
currentResolutionContext
,
argtypes
);
for
(
Symbol
sym
:
polymorphicSignatureScope
.
getSymbolsByName
(
spMethod
.
name
))
{
if
(
types
.
isSameType
(
mtype
,
sym
.
type
))
{
return
sym
;
// Check that there is already a method symbol for the method
// type and owner
if
(
types
.
isSameType
(
mtype
,
sym
.
type
)
&&
spMethod
.
owner
==
sym
.
owner
)
{
return
sym
;
}
}
// create the desired method
long
flags
=
ABSTRACT
|
HYPOTHETICAL
|
spMethod
.
flags
()
&
Flags
.
AccessFlags
;
// Create the desired method
// Retain static modifier is to support invocations to
// MethodHandle.linkTo* methods
long
flags
=
ABSTRACT
|
HYPOTHETICAL
|
spMethod
.
flags
()
&
(
Flags
.
AccessFlags
|
Flags
.
STATIC
);
Symbol
msym
=
new
MethodSymbol
(
flags
,
spMethod
.
name
,
mtype
,
spMethod
.
owner
)
{
@Override
public
Symbol
baseSymbol
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录