Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
6a3e17ac
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看板
提交
6a3e17ac
编写于
3月 25, 2009
作者:
M
mcimadamore
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6400189: raw types and inference
Summary: Fixed resolution problem with raw overriding (CCC) Reviewed-by: jjg
上级
35af7b2d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
230 addition
and
14 deletion
+230
-14
src/share/classes/com/sun/tools/javac/comp/Resolve.java
src/share/classes/com/sun/tools/javac/comp/Resolve.java
+37
-14
test/tools/javac/OverrideChecks/6400189/T6400189a.java
test/tools/javac/OverrideChecks/6400189/T6400189a.java
+38
-0
test/tools/javac/OverrideChecks/6400189/T6400189a.out
test/tools/javac/OverrideChecks/6400189/T6400189a.out
+4
-0
test/tools/javac/OverrideChecks/6400189/T6400189b.java
test/tools/javac/OverrideChecks/6400189/T6400189b.java
+49
-0
test/tools/javac/OverrideChecks/6400189/T6400189b.out
test/tools/javac/OverrideChecks/6400189/T6400189b.out
+4
-0
test/tools/javac/OverrideChecks/6400189/T6400189c.java
test/tools/javac/OverrideChecks/6400189/T6400189c.java
+45
-0
test/tools/javac/OverrideChecks/6400189/T6400189d.java
test/tools/javac/OverrideChecks/6400189/T6400189d.java
+53
-0
未找到文件。
src/share/classes/com/sun/tools/javac/comp/Resolve.java
浏览文件 @
6a3e17ac
...
...
@@ -216,7 +216,9 @@ public class Resolve {
&&
isAccessible
(
env
,
site
)
&&
sym
.
isInheritedIn
(
site
.
tsym
,
types
);
sym
.
isInheritedIn
(
site
.
tsym
,
types
)
&&
notOverriddenIn
(
site
,
sym
);
case
PROTECTED:
return
(
env
.
toplevel
.
packge
==
sym
.
owner
.
owner
// fast special case
...
...
@@ -231,14 +233,23 @@ public class Resolve {
&&
isAccessible
(
env
,
site
)
&&
// `sym' is accessible only if not overridden by
// another symbol which is a member of `site'
// (because, if it is overridden, `sym' is not strictly
// speaking a member of `site'.)
(
sym
.
kind
!=
MTH
||
sym
.
isConstructor
()
||
sym
.
isStatic
()
||
((
MethodSymbol
)
sym
).
implementation
(
site
.
tsym
,
types
,
true
)
==
sym
);
notOverriddenIn
(
site
,
sym
);
default
:
// this case includes erroneous combinations as well
return
isAccessible
(
env
,
site
);
return
isAccessible
(
env
,
site
)
&&
notOverriddenIn
(
site
,
sym
);
}
}
//where
/* `sym' is accessible only if not overridden by
* another symbol which is a member of `site'
* (because, if it is overridden, `sym' is not strictly
* speaking a member of `site'.)
*/
private
boolean
notOverriddenIn
(
Type
site
,
Symbol
sym
)
{
if
(
sym
.
kind
!=
MTH
||
sym
.
isConstructor
()
||
sym
.
isStatic
())
return
true
;
else
{
Symbol
s2
=
((
MethodSymbol
)
sym
).
implementation
(
site
.
tsym
,
types
,
true
);
return
(
s2
==
null
||
s2
==
sym
);
}
}
//where
...
...
@@ -605,7 +616,7 @@ public class Resolve {
Symbol
mostSpecific
(
Symbol
m1
,
Symbol
m2
,
Env
<
AttrContext
>
env
,
Type
site
,
final
Type
site
,
boolean
allowBoxing
,
boolean
useVarargs
)
{
switch
(
m2
.
kind
)
{
...
...
@@ -661,21 +672,33 @@ public class Resolve {
m2
.
erasure
(
types
).
getParameterTypes
()))
return
new
AmbiguityError
(
m1
,
m2
);
// both abstract, neither overridden; merge throws clause and result type
Symbol
result
;
Symbol
mostSpecific
;
Type
result2
=
mt2
.
getReturnType
();
if
(
mt2
.
tag
==
FORALL
)
result2
=
types
.
subst
(
result2
,
((
ForAll
)
mt2
).
tvars
,
((
ForAll
)
mt1
).
tvars
);
if
(
types
.
isSubtype
(
mt1
.
getReturnType
(),
result2
))
{
result
=
m1
;
mostSpecific
=
m1
;
}
else
if
(
types
.
isSubtype
(
result2
,
mt1
.
getReturnType
()))
{
result
=
m2
;
mostSpecific
=
m2
;
}
else
{
// Theoretically, this can't happen, but it is possible
// due to error recovery or mixing incompatible class files
return
new
AmbiguityError
(
m1
,
m2
);
}
result
=
result
.
clone
(
result
.
owner
);
result
.
type
=
(
Type
)
result
.
type
.
clone
();
MethodSymbol
result
=
new
MethodSymbol
(
mostSpecific
.
flags
(),
mostSpecific
.
name
,
null
,
mostSpecific
.
owner
)
{
@Override
public
MethodSymbol
implementation
(
TypeSymbol
origin
,
Types
types
,
boolean
checkResult
)
{
if
(
origin
==
site
.
tsym
)
return
this
;
else
return
super
.
implementation
(
origin
,
types
,
checkResult
);
}
};
result
.
type
=
(
Type
)
mostSpecific
.
type
.
clone
();
result
.
type
.
setThrown
(
chk
.
intersect
(
mt1
.
getThrownTypes
(),
mt2
.
getThrownTypes
()));
return
result
;
...
...
test/tools/javac/OverrideChecks/6400189/T6400189a.java
0 → 100644
浏览文件 @
6a3e17ac
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6400189
* @summary raw types and inference
* @author mcimadamore
* @compile/fail/ref=T6400189a.out T6400189a.java -Xlint:unchecked -XDrawDiagnostics
*/
import
java.lang.reflect.Constructor
;
import
java.lang.annotation.Documented
;
class
T6400189a
{
Constructor
c
=
null
;
Documented
d
=
c
.
getAnnotation
(
Documented
.
class
);
}
test/tools/javac/OverrideChecks/6400189/T6400189a.out
0 → 100644
浏览文件 @
6a3e17ac
T6400189a.java:37:35: compiler.warn.unchecked.call.mbr.of.raw.type: <T>getAnnotation(java.lang.Class<T>), java.lang.reflect.Constructor
T6400189a.java:37:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.annotation.Annotation, java.lang.annotation.Documented
1 error
1 warning
test/tools/javac/OverrideChecks/6400189/T6400189b.java
0 → 100644
浏览文件 @
6a3e17ac
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6400189
* @summary raw types and inference
* @author mcimadamore
* @compile/fail/ref=T6400189b.out T6400189b.java -Xlint:unchecked -XDrawDiagnostics
*/
class
T6400189b
<
T
>
{
static
class
A
{
<
T
>
T
m
(
T6400189b
<
T
>
x
)
{
return
null
;
}
}
static
class
B
<
T
>
extends
A
{
<
T
>
T
m
(
T6400189b
<
T
>
x
)
{
return
null
;
}
}
void
test
(
B
b
)
{
Integer
i
=
b
.
m
(
new
T6400189b
<
Integer
>());
}
}
test/tools/javac/OverrideChecks/6400189/T6400189b.out
0 → 100644
浏览文件 @
6a3e17ac
T6400189b.java:47:24: compiler.warn.unchecked.call.mbr.of.raw.type: <T>m(T6400189b<T>), T6400189b.B
T6400189b.java:47:24: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Object, java.lang.Integer
1 error
1 warning
test/tools/javac/OverrideChecks/6400189/T6400189c.java
0 → 100644
浏览文件 @
6a3e17ac
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6400189
* @summary raw types and inference
* @author mcimadamore
* @compile T6400189c.java
*/
class
T6400189c
<
T
>
{
static
class
A
{
<
T
>
T
m
(
T6400189c
<
T
>
x
)
{
return
null
;
}
}
static
class
B
<
T
>
extends
A
{}
void
test
(
B
b
)
{
Integer
i
=
b
.
m
(
new
T6400189c
<
Integer
>());
}
}
test/tools/javac/OverrideChecks/6400189/T6400189d.java
0 → 100644
浏览文件 @
6a3e17ac
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6400189
* @summary raw types and inference
* @author mcimadamore
* @compile T6400189d.java
*/
import
java.util.Iterator
;
class
T6400189c
<
T
>
{
interface
A
<
X
>
extends
Iterable
<
X
>
{
Iterator
<
X
>
iterator
();
}
interface
A2
<
Y
>
extends
A
<
Y
>
{
Iterator
<
Y
>
iterator
();
}
static
abstract
class
B
<
Z
>
implements
A
<
Z
>
{
public
abstract
Iterator
<
Z
>
iterator
();
}
static
abstract
class
C
<
W
>
extends
B
<
W
>
implements
A2
<
W
>
{
Iterator
<
W
>
test
()
{
return
iterator
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录