Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
a505a1df
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a505a1df
编写于
10月 31, 2014
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
09e65c88
f49a2a3f
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
457 addition
and
282 deletion
+457
-282
src/share/classes/com/sun/tools/javac/code/Types.java
src/share/classes/com/sun/tools/javac/code/Types.java
+47
-28
src/share/classes/com/sun/tools/javac/comp/Attr.java
src/share/classes/com/sun/tools/javac/comp/Attr.java
+6
-2
src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
+240
-245
src/share/classes/com/sun/tools/javac/jvm/Code.java
src/share/classes/com/sun/tools/javac/jvm/Code.java
+6
-7
test/tools/javac/annotations/FinalStringInNested.java
test/tools/javac/annotations/FinalStringInNested.java
+46
-0
test/tools/javac/generics/inference/8058511/T8058511a.java
test/tools/javac/generics/inference/8058511/T8058511a.java
+38
-0
test/tools/javac/generics/inference/8058511/T8058511b.java
test/tools/javac/generics/inference/8058511/T8058511b.java
+36
-0
test/tools/javac/generics/inference/8058511/T8058511c.java
test/tools/javac/generics/inference/8058511/T8058511c.java
+38
-0
未找到文件。
src/share/classes/com/sun/tools/javac/code/Types.java
浏览文件 @
a505a1df
...
@@ -1892,7 +1892,12 @@ public class Types {
...
@@ -1892,7 +1892,12 @@ public class Types {
* Mapping to take element type of an arraytype
* Mapping to take element type of an arraytype
*/
*/
private
Mapping
elemTypeFun
=
new
Mapping
(
"elemTypeFun"
)
{
private
Mapping
elemTypeFun
=
new
Mapping
(
"elemTypeFun"
)
{
public
Type
apply
(
Type
t
)
{
return
elemtype
(
t
);
}
public
Type
apply
(
Type
t
)
{
while
(
t
.
hasTag
(
TYPEVAR
))
{
t
=
t
.
getUpperBound
();
}
return
elemtype
(
t
);
}
};
};
/**
/**
...
@@ -3521,40 +3526,46 @@ public class Types {
...
@@ -3521,40 +3526,46 @@ public class Types {
}
}
/**
/**
* Return the least upper bound of
pair
of types. if the lub does
* Return the least upper bound of
list
of types. if the lub does
* not exist return null.
* not exist return null.
*/
*/
public
Type
lub
(
Type
t1
,
Type
t2
)
{
public
Type
lub
(
List
<
Type
>
ts
)
{
return
lub
(
List
.
of
(
t1
,
t2
));
return
lub
(
ts
.
toArray
(
new
Type
[
ts
.
length
()]
));
}
}
/**
/**
* Return the least upper bound (lub) of set of types. If the lub
* Return the least upper bound (lub) of set of types. If the lub
* does not exist return the type of null (bottom).
* does not exist return the type of null (bottom).
*/
*/
public
Type
lub
(
List
<
Type
>
ts
)
{
public
Type
lub
(
Type
...
ts
)
{
final
int
UNKNOWN_BOUND
=
0
;
final
int
ARRAY_BOUND
=
1
;
final
int
ARRAY_BOUND
=
1
;
final
int
CLASS_BOUND
=
2
;
final
int
CLASS_BOUND
=
2
;
int
boundkind
=
0
;
for
(
Type
t
:
ts
)
{
int
[]
kinds
=
new
int
[
ts
.
length
];
int
boundkind
=
UNKNOWN_BOUND
;
for
(
int
i
=
0
;
i
<
ts
.
length
;
i
++)
{
Type
t
=
ts
[
i
];
switch
(
t
.
getTag
())
{
switch
(
t
.
getTag
())
{
case
CLASS:
case
CLASS:
boundkind
|=
CLASS_BOUND
;
boundkind
|=
kinds
[
i
]
=
CLASS_BOUND
;
break
;
break
;
case
ARRAY:
case
ARRAY:
boundkind
|=
ARRAY_BOUND
;
boundkind
|=
kinds
[
i
]
=
ARRAY_BOUND
;
break
;
break
;
case
TYPEVAR:
case
TYPEVAR:
do
{
do
{
t
=
t
.
getUpperBound
();
t
=
t
.
getUpperBound
();
}
while
(
t
.
hasTag
(
TYPEVAR
));
}
while
(
t
.
hasTag
(
TYPEVAR
));
if
(
t
.
hasTag
(
ARRAY
))
{
if
(
t
.
hasTag
(
ARRAY
))
{
boundkind
|=
ARRAY_BOUND
;
boundkind
|=
kinds
[
i
]
=
ARRAY_BOUND
;
}
else
{
}
else
{
boundkind
|=
CLASS_BOUND
;
boundkind
|=
kinds
[
i
]
=
CLASS_BOUND
;
}
}
break
;
break
;
default
:
default
:
kinds
[
i
]
=
UNKNOWN_BOUND
;
if
(
t
.
isPrimitive
())
if
(
t
.
isPrimitive
())
return
syms
.
errType
;
return
syms
.
errType
;
}
}
...
@@ -3565,15 +3576,16 @@ public class Types {
...
@@ -3565,15 +3576,16 @@ public class Types {
case
ARRAY_BOUND:
case
ARRAY_BOUND:
// calculate lub(A[], B[])
// calculate lub(A[], B[])
List
<
Type
>
elements
=
Type
.
map
(
ts
,
elemTypeFun
);
Type
[]
elements
=
new
Type
[
ts
.
length
];
for
(
Type
t
:
elements
)
{
for
(
int
i
=
0
;
i
<
ts
.
length
;
i
++)
{
if
(
t
.
isPrimitive
())
{
Type
elem
=
elements
[
i
]
=
elemTypeFun
.
apply
(
ts
[
i
]);
if
(
elem
.
isPrimitive
())
{
// if a primitive type is found, then return
// if a primitive type is found, then return
// arraySuperType unless all the types are the
// arraySuperType unless all the types are the
// same
// same
Type
first
=
ts
.
head
;
Type
first
=
ts
[
0
]
;
for
(
Type
s
:
ts
.
tail
)
{
for
(
int
j
=
1
;
j
<
ts
.
length
;
j
++
)
{
if
(!
isSameType
(
first
,
s
))
{
if
(!
isSameType
(
first
,
ts
[
j
]
))
{
// lub(int[], B[]) is Cloneable & Serializable
// lub(int[], B[]) is Cloneable & Serializable
return
arraySuperType
();
return
arraySuperType
();
}
}
...
@@ -3588,13 +3600,20 @@ public class Types {
...
@@ -3588,13 +3600,20 @@ public class Types {
case
CLASS_BOUND:
case
CLASS_BOUND:
// calculate lub(A, B)
// calculate lub(A, B)
while
(!
ts
.
head
.
hasTag
(
CLASS
)
&&
!
ts
.
head
.
hasTag
(
TYPEVAR
))
{
int
startIdx
=
0
;
ts
=
ts
.
tail
;
for
(
int
i
=
0
;
i
<
ts
.
length
;
i
++)
{
Type
t
=
ts
[
i
];
if
(
t
.
hasTag
(
CLASS
)
||
t
.
hasTag
(
TYPEVAR
))
{
break
;
}
else
{
startIdx
++;
}
}
}
Assert
.
check
(
!
ts
.
isEmpty
()
);
Assert
.
check
(
startIdx
<
ts
.
length
);
//step 1 - compute erased candidate set (EC)
//step 1 - compute erased candidate set (EC)
List
<
Type
>
cl
=
erasedSupertypes
(
ts
.
head
);
List
<
Type
>
cl
=
erasedSupertypes
(
ts
[
startIdx
]);
for
(
Type
t
:
ts
.
tail
)
{
for
(
int
i
=
startIdx
+
1
;
i
<
ts
.
length
;
i
++)
{
Type
t
=
ts
[
i
];
if
(
t
.
hasTag
(
CLASS
)
||
t
.
hasTag
(
TYPEVAR
))
if
(
t
.
hasTag
(
CLASS
)
||
t
.
hasTag
(
TYPEVAR
))
cl
=
intersect
(
cl
,
erasedSupertypes
(
t
));
cl
=
intersect
(
cl
,
erasedSupertypes
(
t
));
}
}
...
@@ -3603,9 +3622,9 @@ public class Types {
...
@@ -3603,9 +3622,9 @@ public class Types {
//step 3 - for each element G in MEC, compute lci(Inv(G))
//step 3 - for each element G in MEC, compute lci(Inv(G))
List
<
Type
>
candidates
=
List
.
nil
();
List
<
Type
>
candidates
=
List
.
nil
();
for
(
Type
erasedSupertype
:
mec
)
{
for
(
Type
erasedSupertype
:
mec
)
{
List
<
Type
>
lci
=
List
.
of
(
asSuper
(
ts
.
head
,
erasedSupertype
.
tsym
));
List
<
Type
>
lci
=
List
.
of
(
asSuper
(
ts
[
startIdx
]
,
erasedSupertype
.
tsym
));
for
(
Type
t
:
ts
)
{
for
(
int
i
=
startIdx
+
1
;
i
<
ts
.
length
;
i
++
)
{
lci
=
intersect
(
lci
,
List
.
of
(
asSuper
(
t
,
erasedSupertype
.
tsym
)));
lci
=
intersect
(
lci
,
List
.
of
(
asSuper
(
t
s
[
i
]
,
erasedSupertype
.
tsym
)));
}
}
candidates
=
candidates
.
appendList
(
lci
);
candidates
=
candidates
.
appendList
(
lci
);
}
}
...
@@ -3616,9 +3635,9 @@ public class Types {
...
@@ -3616,9 +3635,9 @@ public class Types {
default
:
default
:
// calculate lub(A, B[])
// calculate lub(A, B[])
List
<
Type
>
classes
=
List
.
of
(
arraySuperType
());
List
<
Type
>
classes
=
List
.
of
(
arraySuperType
());
for
(
Type
t
:
ts
)
{
for
(
int
i
=
0
;
i
<
ts
.
length
;
i
++
)
{
if
(
!
t
.
hasTag
(
ARRAY
)
)
// Filter out any arrays
if
(
kinds
[
i
]
!=
ARRAY_BOUND
)
// Filter out any arrays
classes
=
classes
.
prepend
(
t
);
classes
=
classes
.
prepend
(
t
s
[
i
]
);
}
}
// lub(A, B[]) is lub(A, arraySuperType)
// lub(A, B[]) is lub(A, arraySuperType)
return
lub
(
classes
);
return
lub
(
classes
);
...
...
src/share/classes/com/sun/tools/javac/comp/Attr.java
浏览文件 @
a505a1df
...
@@ -1010,8 +1010,12 @@ public class Attr extends JCTree.Visitor {
...
@@ -1010,8 +1010,12 @@ public class Attr extends JCTree.Visitor {
// parameters have already been entered
// parameters have already been entered
env
.
info
.
scope
.
enter
(
tree
.
sym
);
env
.
info
.
scope
.
enter
(
tree
.
sym
);
}
else
{
}
else
{
memberEnter
.
memberEnter
(
tree
,
env
);
try
{
annotate
.
flush
();
annotate
.
enterStart
();
memberEnter
.
memberEnter
(
tree
,
env
);
}
finally
{
annotate
.
enterDone
();
}
}
}
}
else
{
}
else
{
if
(
tree
.
init
!=
null
)
{
if
(
tree
.
init
!=
null
)
{
...
...
src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
浏览文件 @
a505a1df
此差异已折叠。
点击以展开。
src/share/classes/com/sun/tools/javac/jvm/Code.java
浏览文件 @
a505a1df
...
@@ -2017,13 +2017,12 @@ public class Code {
...
@@ -2017,13 +2017,12 @@ public class Code {
List
<
VarSymbol
>
locals
=
lvtRanges
.
getVars
(
meth
,
tree
);
List
<
VarSymbol
>
locals
=
lvtRanges
.
getVars
(
meth
,
tree
);
for
(
LocalVar
localVar:
lvar
)
{
for
(
LocalVar
localVar:
lvar
)
{
for
(
VarSymbol
aliveLocal
:
locals
)
{
for
(
VarSymbol
aliveLocal
:
locals
)
{
if
(
localVar
==
null
)
{
if
(
localVar
!=
null
)
{
return
;
if
(
localVar
.
sym
==
aliveLocal
&&
localVar
.
lastRange
()
!=
null
)
{
}
char
length
=
(
char
)(
closingCP
-
localVar
.
lastRange
().
start_pc
);
if
(
localVar
.
sym
==
aliveLocal
&&
localVar
.
lastRange
()
!=
null
)
{
if
(
length
<
Character
.
MAX_VALUE
)
{
char
length
=
(
char
)(
closingCP
-
localVar
.
lastRange
().
start_pc
);
localVar
.
closeRange
(
length
);
if
(
length
<
Character
.
MAX_VALUE
)
{
}
localVar
.
closeRange
(
length
);
}
}
}
}
}
}
...
...
test/tools/javac/annotations/FinalStringInNested.java
0 → 100644
浏览文件 @
a505a1df
/*
* Copyright (c) 2014, 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.
*/
/*
* @test
* @bug 8054448
* @summary Verify that constant strings in nested classes in anonymous classes
* can be used in annotations.
* @compile FinalStringInNested.java
*/
public
class
FinalStringInNested
{
public
void
f
()
{
Object
o
=
new
Object
()
{
@FinalStringInNested
.
Annotation
(
Nested
.
ID
)
class
Nested
{
static
final
String
ID
=
"B"
;
}
};
}
@interface
Annotation
{
String
value
();
}
}
test/tools/javac/generics/inference/8058511/T8058511a.java
0 → 100644
浏览文件 @
a505a1df
/*
* Copyright (c) 2014, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
/**
* @test
* @bug 8058511
* @summary StackOverflowError at com.sun.tools.javac.code.Types.lub
* @compile T8058511a.java
*/
class
T8058511a
{
<
Z
>
void
choose
(
Z
z1
,
Z
z2
)
{
}
void
test
(
Class
<
Double
>
cd
,
Class
<?
extends
double
[]>
cdarr
)
{
choose
(
cd
,
cdarr
);
}
}
test/tools/javac/generics/inference/8058511/T8058511b.java
0 → 100644
浏览文件 @
a505a1df
/*
* Copyright (c) 2014, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
/**
* @test
* @bug 8058511
* @summary StackOverflowError at com.sun.tools.javac.code.Types.lub
* @compile T8058511b.java
*/
class
T8058511b
{
void
test
(
Class
<
Double
>
cd
,
Class
<?
extends
double
[]>
cdarr
)
{
((
false
)
?
cd
:
cdarr
).
toString
();
}
}
test/tools/javac/generics/inference/8058511/T8058511c.java
0 → 100644
浏览文件 @
a505a1df
/*
* Copyright (c) 2014, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
/**
* @test
* @bug 8058511
* @summary StackOverflowError at com.sun.tools.javac.code.Types.lub
* @compile T8058511c.java
*/
import
java.util.List
;
class
T8058511c
{
void
test
(
List
<?
extends
double
[]>
l
)
{
(
true
?
l
.
get
(
0
)
:
l
.
get
(
0
)).
toString
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录