Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
c04ac9d8
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看板
提交
c04ac9d8
编写于
8月 21, 2015
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8071291: Compiler crashes trying to cast UnionType to IntersectionClassType
Reviewed-by: mcimadamore
上级
4321718d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
122 addition
and
44 deletion
+122
-44
src/share/classes/com/sun/tools/javac/code/Type.java
src/share/classes/com/sun/tools/javac/code/Type.java
+18
-0
src/share/classes/com/sun/tools/javac/code/Types.java
src/share/classes/com/sun/tools/javac/code/Types.java
+49
-37
src/share/classes/com/sun/tools/javac/comp/Attr.java
src/share/classes/com/sun/tools/javac/comp/Attr.java
+3
-4
src/share/classes/com/sun/tools/javac/comp/Check.java
src/share/classes/com/sun/tools/javac/comp/Check.java
+1
-1
src/share/classes/com/sun/tools/javac/comp/Infer.java
src/share/classes/com/sun/tools/javac/comp/Infer.java
+1
-1
src/share/classes/com/sun/tools/javac/comp/TransTypes.java
src/share/classes/com/sun/tools/javac/comp/TransTypes.java
+1
-1
test/tools/javac/multicatch/8071291/T8071291.java
test/tools/javac/multicatch/8071291/T8071291.java
+49
-0
未找到文件。
src/share/classes/com/sun/tools/javac/code/Type.java
浏览文件 @
c04ac9d8
...
...
@@ -421,6 +421,14 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
&&
(
tsym
.
flags
()
&
COMPOUND
)
!=
0
;
}
public
boolean
isIntersection
()
{
return
false
;
}
public
boolean
isUnion
()
{
return
false
;
}
public
boolean
isInterface
()
{
return
(
tsym
.
flags
()
&
INTERFACE
)
!=
0
;
}
...
...
@@ -969,6 +977,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
return
Collections
.
unmodifiableList
(
alternatives_field
);
}
@Override
public
boolean
isUnion
()
{
return
true
;
}
@Override
public
TypeKind
getKind
()
{
return
TypeKind
.
UNION
;
...
...
@@ -1003,6 +1016,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
return
interfaces_field
.
prepend
(
supertype_field
);
}
@Override
public
boolean
isIntersection
()
{
return
true
;
}
public
List
<
Type
>
getExplicitComponents
()
{
return
allInterfaces
?
interfaces_field
:
...
...
src/share/classes/com/sun/tools/javac/code/Types.java
浏览文件 @
c04ac9d8
...
...
@@ -1539,8 +1539,8 @@ public class Types {
}
}
if
(
t
.
is
Compound
()
||
s
.
isCompound
())
{
return
!
t
.
is
Compound
()
?
if
(
t
.
is
Intersection
()
||
s
.
isIntersection
())
{
return
!
t
.
is
Intersection
()
?
visitIntersectionType
((
IntersectionClassType
)
s
.
unannotatedType
(),
t
,
true
)
:
visitIntersectionType
((
IntersectionClassType
)
t
.
unannotatedType
(),
s
,
false
);
}
...
...
@@ -2255,19 +2255,28 @@ public class Types {
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="make
Compound
Type">
// <editor-fold defaultstate="collapsed" desc="make
Intersection
Type">
/**
* Make a compound type from non-empty list of types. The list should be
* ordered according to {@link Symbol#precedes(TypeSymbol,Types)}.
* Make an intersection type from non-empty list of types. The list should be ordered according to
* {@link TypeSymbol#precedes(TypeSymbol, Types)}. Note that this might cause a symbol completion.
* Hence, this version of makeIntersectionType may not be called during a classfile read.
*
* @param bounds the types from which the compound type is formed
* @param supertype is objectType if all bounds are interfaces,
* null otherwise.
* @param bounds the types from which the intersection type is formed
*/
public
Type
makeCompound
Type
(
List
<
Type
>
bounds
)
{
return
make
Compound
Type
(
bounds
,
bounds
.
head
.
tsym
.
isInterface
());
public
IntersectionClassType
makeIntersection
Type
(
List
<
Type
>
bounds
)
{
return
make
Intersection
Type
(
bounds
,
bounds
.
head
.
tsym
.
isInterface
());
}
public
Type
makeCompoundType
(
List
<
Type
>
bounds
,
boolean
allInterfaces
)
{
/**
* Make an intersection type from non-empty list of types. The list should be ordered according to
* {@link TypeSymbol#precedes(TypeSymbol, Types)}. This does not cause symbol completion as
* an extra parameter indicates as to whether all bounds are interfaces - in which case the
* supertype is implicitly assumed to be 'Object'.
*
* @param bounds the types from which the intersection type is formed
* @param allInterfaces are all bounds interface types?
*/
public
IntersectionClassType
makeIntersectionType
(
List
<
Type
>
bounds
,
boolean
allInterfaces
)
{
Assert
.
check
(
bounds
.
nonEmpty
());
Type
firstExplicitBound
=
bounds
.
head
;
if
(
allInterfaces
)
{
...
...
@@ -2280,23 +2289,24 @@ public class Types {
:
names
.
empty
,
null
,
syms
.
noSymbol
);
bc
.
type
=
new
IntersectionClassType
(
bounds
,
bc
,
allInterfaces
);
IntersectionClassType
intersectionType
=
new
IntersectionClassType
(
bounds
,
bc
,
allInterfaces
);
bc
.
type
=
intersectionType
;
bc
.
erasure_field
=
(
bounds
.
head
.
hasTag
(
TYPEVAR
))
?
syms
.
objectType
:
// error condition, recover
erasure
(
firstExplicitBound
);
bc
.
members_field
=
new
Scope
(
bc
);
return
bc
.
t
ype
;
return
intersectionT
ype
;
}
/**
* A convenience wrapper for {@link #make
Compound
Type(List)}; the
* A convenience wrapper for {@link #make
Intersection
Type(List)}; the
* arguments are converted to a list and passed to the other
* method. Note that this might cause a symbol completion.
* Hence, this version of make
Compound
Type may not be called
* Hence, this version of make
Intersection
Type may not be called
* during a classfile read.
*/
public
Type
make
Compound
Type
(
Type
bound1
,
Type
bound2
)
{
return
make
Compound
Type
(
List
.
of
(
bound1
,
bound2
));
public
Type
make
Intersection
Type
(
Type
bound1
,
Type
bound2
)
{
return
make
Intersection
Type
(
List
.
of
(
bound1
,
bound2
));
}
// </editor-fold>
...
...
@@ -2436,7 +2446,7 @@ public class Types {
private
final
UnaryVisitor
<
List
<
Type
>>
directSupertypes
=
new
UnaryVisitor
<
List
<
Type
>>()
{
public
List
<
Type
>
visitType
(
final
Type
type
,
final
Void
ignored
)
{
if
(!
type
.
is
Compound
())
{
if
(!
type
.
is
Intersection
())
{
final
Type
sup
=
supertype
(
type
);
return
(
sup
==
Type
.
noType
||
sup
==
type
||
sup
==
null
)
?
interfaces
(
type
)
...
...
@@ -2490,30 +2500,32 @@ public class Types {
// <editor-fold defaultstate="collapsed" desc="setBounds">
/**
* Set the bounds field of the given type variable to reflect a
* (possibly multiple) list of bounds.
* @param t a type variable
* @param bounds the bounds, must be nonempty
* @param supertype is objectType if all bounds are interfaces,
* null otherwise.
* Same as {@link Types#setBounds(TypeVar, List, boolean)}, except that third parameter is computed directly,
* as follows: if all all bounds are interface types, the computed supertype is Object,otherwise
* the supertype is simply left null (in this case, the supertype is assumed to be the head of
* the bound list passed as second argument). Note that this check might cause a symbol completion.
* Hence, this version of setBounds may not be called during a classfile read.
*
* @param t a type variable
* @param bounds the bounds, must be nonempty
*/
public
void
setBounds
(
TypeVar
t
,
List
<
Type
>
bounds
)
{
setBounds
(
t
,
bounds
,
bounds
.
head
.
tsym
.
isInterface
());
}
/**
* S
ame as {@link #setBounds(Type.TypeVar,List,Type)}, except that
*
third parameter is computed directly, as follows: if all
* a
ll bounds are interface types, the computed supertype is Object,
*
otherwise the supertype is simply left null (in this case, the supertype
*
is assumed to be the head of the bound list passed as second argument).
*
Note that this check might cause a symbol completion. Hence, this version of
*
setBounds may not be called during a classfile read.
* S
et the bounds field of the given type variable to reflect a (possibly multiple) list of bounds.
*
This does not cause symbol completion as an extra parameter indicates as to whether all bounds
* a
re interfaces - in which case the supertype is implicitly assumed to be 'Object'.
*
*
@param t a type variable
*
@param bounds the bounds, must be nonempty
*
@param allInterfaces are all bounds interface types?
*/
public
void
setBounds
(
TypeVar
t
,
List
<
Type
>
bounds
,
boolean
allInterfaces
)
{
t
.
bound
=
bounds
.
tail
.
isEmpty
()
?
bounds
.
head
:
make
Compound
Type
(
bounds
,
allInterfaces
);
make
Intersection
Type
(
bounds
,
allInterfaces
);
t
.
rank_field
=
-
1
;
}
// </editor-fold>
...
...
@@ -3063,7 +3075,7 @@ public class Types {
if
(
st
==
supertype
(
t
)
&&
is
==
interfaces
(
t
))
return
t
;
else
return
make
Compound
Type
(
is
.
prepend
(
st
));
return
make
Intersection
Type
(
is
.
prepend
(
st
));
}
}
...
...
@@ -3566,7 +3578,7 @@ public class Types {
else
if
(
compound
.
tail
.
isEmpty
())
return
compound
.
head
;
else
return
make
Compound
Type
(
compound
);
return
make
Intersection
Type
(
compound
);
}
/**
...
...
@@ -3744,8 +3756,8 @@ public class Types {
synchronized
(
this
)
{
if
(
arraySuperType
==
null
)
{
// JLS 10.8: all arrays implement Cloneable and Serializable.
arraySuperType
=
make
Compound
Type
(
List
.
of
(
syms
.
serializableType
,
syms
.
cloneableType
),
true
);
arraySuperType
=
make
Intersection
Type
(
List
.
of
(
syms
.
serializableType
,
syms
.
cloneableType
),
true
);
}
}
}
...
...
@@ -3811,7 +3823,7 @@ public class Types {
return
glbFlattened
(
union
(
bounds
,
lowers
),
errT
);
}
}
return
make
Compound
Type
(
bounds
);
return
make
Intersection
Type
(
bounds
);
}
// </editor-fold>
...
...
src/share/classes/com/sun/tools/javac/comp/Attr.java
浏览文件 @
c04ac9d8
...
...
@@ -2434,7 +2434,7 @@ public class Attr extends JCTree.Visitor {
@Override
public
Type
visitClassType
(
ClassType
t
,
DiagnosticPosition
pos
)
{
return
t
.
is
Compound
()
?
return
t
.
is
Intersection
()
?
visitIntersectionClassType
((
IntersectionClassType
)
t
,
pos
)
:
t
;
}
...
...
@@ -2465,8 +2465,7 @@ public class Attr extends JCTree.Visitor {
}
supertypes
.
append
(
i
.
tsym
.
type
);
}
IntersectionClassType
notionalIntf
=
(
IntersectionClassType
)
types
.
makeCompoundType
(
supertypes
.
toList
());
IntersectionClassType
notionalIntf
=
types
.
makeIntersectionType
(
supertypes
.
toList
());
notionalIntf
.
allparams_field
=
targs
.
toList
();
notionalIntf
.
tsym
.
flags_field
|=
INTERFACE
;
return
notionalIntf
.
tsym
;
...
...
@@ -4032,7 +4031,7 @@ public class Attr extends JCTree.Visitor {
}
else
if
(
bounds
.
length
()
==
1
)
{
return
bounds
.
head
.
type
;
}
else
{
Type
owntype
=
types
.
make
Compound
Type
(
TreeInfo
.
types
(
bounds
));
Type
owntype
=
types
.
make
Intersection
Type
(
TreeInfo
.
types
(
bounds
));
// ... the variable's bound is a class type flagged COMPOUND
// (see comment for TypeVar.bound).
// In this case, generate a class tree that represents the
...
...
src/share/classes/com/sun/tools/javac/comp/Check.java
浏览文件 @
c04ac9d8
...
...
@@ -1813,7 +1813,7 @@ public class Check {
Type
t1
,
Type
t2
)
{
return
checkCompatibleAbstracts
(
pos
,
t1
,
t2
,
types
.
make
Compound
Type
(
t1
,
t2
));
types
.
make
Intersection
Type
(
t1
,
t2
));
}
public
boolean
checkCompatibleAbstracts
(
DiagnosticPosition
pos
,
...
...
src/share/classes/com/sun/tools/javac/comp/Infer.java
浏览文件 @
c04ac9d8
...
...
@@ -373,7 +373,7 @@ public class Infer {
List
<
Type
>
upperBounds
=
uv
.
getBounds
(
InferenceBound
.
UPPER
);
if
(
Type
.
containsAny
(
upperBounds
,
vars
))
{
TypeSymbol
fresh_tvar
=
new
TypeVariableSymbol
(
Flags
.
SYNTHETIC
,
uv
.
qtype
.
tsym
.
name
,
null
,
uv
.
qtype
.
tsym
.
owner
);
fresh_tvar
.
type
=
new
TypeVar
(
fresh_tvar
,
types
.
make
Compound
Type
(
uv
.
getBounds
(
InferenceBound
.
UPPER
)),
null
);
fresh_tvar
.
type
=
new
TypeVar
(
fresh_tvar
,
types
.
make
Intersection
Type
(
uv
.
getBounds
(
InferenceBound
.
UPPER
)),
null
);
todo
.
append
(
uv
);
uv
.
inst
=
fresh_tvar
.
type
;
}
else
if
(
upperBounds
.
nonEmpty
())
{
...
...
src/share/classes/com/sun/tools/javac/comp/TransTypes.java
浏览文件 @
c04ac9d8
...
...
@@ -750,7 +750,7 @@ public class TransTypes extends TreeTranslator {
Type
originalTarget
=
tree
.
type
;
tree
.
type
=
erasure
(
tree
.
type
);
tree
.
expr
=
translate
(
tree
.
expr
,
tree
.
type
);
if
(
originalTarget
.
is
Compound
())
{
if
(
originalTarget
.
is
Intersection
())
{
Type
.
IntersectionClassType
ict
=
(
Type
.
IntersectionClassType
)
originalTarget
;
for
(
Type
c
:
ict
.
getExplicitComponents
())
{
Type
ec
=
erasure
(
c
);
...
...
test/tools/javac/multicatch/8071291/T8071291.java
0 → 100644
浏览文件 @
c04ac9d8
/*
* Copyright (c) 2015, 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 8071291
* @summary Compiler crashes trying to cast UnionType to IntersectionClassType
* @compile T8071291.java
*/
class
T8071291
{
interface
A
{
}
class
Exception1
extends
Exception
implements
A
{
}
class
Exception2
extends
Exception
implements
A
{
}
void
test
(
boolean
cond
)
{
try
{
if
(
cond
)
{
throw
new
Exception1
();
}
else
{
throw
new
Exception2
();
}
}
catch
(
Exception1
|
Exception2
x
)
{
if
(
x
instanceof
Exception1
)
{
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录