Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
e5206d1f
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看板
提交
e5206d1f
编写于
10月 24, 2008
作者:
T
tbell
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
54d59148
fd378443
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
972 addition
and
153 deletion
+972
-153
src/share/classes/com/sun/tools/javac/api/Formattable.java
src/share/classes/com/sun/tools/javac/api/Formattable.java
+19
-0
src/share/classes/com/sun/tools/javac/code/Symbol.java
src/share/classes/com/sun/tools/javac/code/Symbol.java
+5
-1
src/share/classes/com/sun/tools/javac/code/Type.java
src/share/classes/com/sun/tools/javac/code/Type.java
+0
-15
src/share/classes/com/sun/tools/javac/code/Types.java
src/share/classes/com/sun/tools/javac/code/Types.java
+64
-33
src/share/classes/com/sun/tools/javac/comp/Attr.java
src/share/classes/com/sun/tools/javac/comp/Attr.java
+17
-10
src/share/classes/com/sun/tools/javac/comp/Check.java
src/share/classes/com/sun/tools/javac/comp/Check.java
+49
-45
src/share/classes/com/sun/tools/javac/comp/Resolve.java
src/share/classes/com/sun/tools/javac/comp/Resolve.java
+109
-30
src/share/classes/com/sun/tools/javac/resources/compiler.properties
...classes/com/sun/tools/javac/resources/compiler.properties
+7
-1
test/tools/javac/6758789/T6758789a.java
test/tools/javac/6758789/T6758789a.java
+40
-0
test/tools/javac/6758789/T6758789a.out
test/tools/javac/6758789/T6758789a.out
+3
-0
test/tools/javac/6758789/T6758789b.java
test/tools/javac/6758789/T6758789b.java
+41
-0
test/tools/javac/6758789/T6758789b.out
test/tools/javac/6758789/T6758789b.out
+3
-0
test/tools/javac/cast/6548436/T6548436a.java
test/tools/javac/cast/6548436/T6548436a.java
+40
-0
test/tools/javac/cast/6548436/T6548436b.java
test/tools/javac/cast/6548436/T6548436b.java
+40
-0
test/tools/javac/cast/6548436/T6548436c.java
test/tools/javac/cast/6548436/T6548436c.java
+42
-0
test/tools/javac/cast/6548436/T6548436d.java
test/tools/javac/cast/6548436/T6548436d.java
+40
-0
test/tools/javac/generics/6487370/T6487370.java
test/tools/javac/generics/6487370/T6487370.java
+56
-0
test/tools/javac/generics/6531090/T6531090b.java
test/tools/javac/generics/6531090/T6531090b.java
+38
-13
test/tools/javac/generics/6711619/T6711619a.java
test/tools/javac/generics/6711619/T6711619a.java
+74
-0
test/tools/javac/generics/6711619/T6711619a.out
test/tools/javac/generics/6711619/T6711619a.out
+7
-0
test/tools/javac/generics/6711619/T6711619b.java
test/tools/javac/generics/6711619/T6711619b.java
+64
-0
test/tools/javac/generics/6711619/T6711619b.out
test/tools/javac/generics/6711619/T6711619b.out
+5
-0
test/tools/javac/generics/T6557954.java
test/tools/javac/generics/T6557954.java
+36
-0
test/tools/javac/generics/inference/6718364/T6718364.out
test/tools/javac/generics/inference/6718364/T6718364.out
+1
-1
test/tools/javac/generics/typevars/6680106/T6680106.java
test/tools/javac/generics/typevars/6680106/T6680106.java
+40
-0
test/tools/javac/generics/typevars/6680106/T6680106.out
test/tools/javac/generics/typevars/6680106/T6680106.out
+13
-0
test/tools/javac/generics/wildcards/6762569/T6762569a.java
test/tools/javac/generics/wildcards/6762569/T6762569a.java
+5
-4
test/tools/javac/generics/wildcards/6762569/T6762569b.java
test/tools/javac/generics/wildcards/6762569/T6762569b.java
+38
-0
test/tools/javac/generics/wildcards/T6732484.java
test/tools/javac/generics/wildcards/T6732484.java
+37
-0
test/tools/javac/varargs/T6746184.java
test/tools/javac/varargs/T6746184.java
+39
-0
未找到文件。
src/share/classes/com/sun/tools/javac/api/Formattable.java
浏览文件 @
e5206d1f
...
...
@@ -49,4 +49,23 @@ public interface Formattable {
* @return a string representing the object's kind
*/
String
getKind
();
static
class
LocalizedString
implements
Formattable
{
String
key
;
public
LocalizedString
(
String
key
)
{
this
.
key
=
key
;
}
public
String
toString
(
java
.
util
.
Locale
l
,
Messages
messages
)
{
return
messages
.
getLocalizedString
(
l
,
key
);
}
public
String
getKind
()
{
return
"LocalizedString"
;
}
public
String
toString
()
{
return
key
;
}
}
}
src/share/classes/com/sun/tools/javac/code/Symbol.java
浏览文件 @
e5206d1f
...
...
@@ -361,6 +361,8 @@ public abstract class Symbol implements Element {
for
(
Symbol
sup
=
clazz
;
sup
!=
null
&&
sup
!=
this
.
owner
;
sup
=
types
.
supertype
(
sup
.
type
).
tsym
)
{
while
(
sup
.
type
.
tag
==
TYPEVAR
)
sup
=
sup
.
type
.
getUpperBound
().
tsym
;
if
(
sup
.
type
.
isErroneous
())
return
true
;
// error recovery
if
((
sup
.
flags
()
&
COMPOUND
)
!=
0
)
...
...
@@ -1183,7 +1185,9 @@ public abstract class Symbol implements Element {
* as possible implementations.
*/
public
MethodSymbol
implementation
(
TypeSymbol
origin
,
Types
types
,
boolean
checkResult
)
{
for
(
Type
t
=
origin
.
type
;
t
.
tag
==
CLASS
;
t
=
types
.
supertype
(
t
))
{
for
(
Type
t
=
origin
.
type
;
t
.
tag
==
CLASS
||
t
.
tag
==
TYPEVAR
;
t
=
types
.
supertype
(
t
))
{
while
(
t
.
tag
==
TYPEVAR
)
t
=
t
.
getUpperBound
();
TypeSymbol
c
=
t
.
tsym
;
for
(
Scope
.
Entry
e
=
c
.
members
().
lookup
(
name
);
e
.
scope
!=
null
;
...
...
src/share/classes/com/sun/tools/javac/code/Type.java
浏览文件 @
e5206d1f
...
...
@@ -360,17 +360,6 @@ public class Type implements PrimitiveType {
public
boolean
isUnbound
()
{
return
false
;
}
public
Type
withTypeVar
(
Type
t
)
{
return
this
;
}
public
static
List
<
Type
>
removeBounds
(
List
<
Type
>
ts
)
{
ListBuffer
<
Type
>
result
=
new
ListBuffer
<
Type
>();
for
(;
ts
.
nonEmpty
();
ts
=
ts
.
tail
)
{
result
.
append
(
ts
.
head
.
removeBounds
());
}
return
result
.
toList
();
}
public
Type
removeBounds
()
{
return
this
;
}
/** The underlying method type of this type.
*/
public
MethodType
asMethodType
()
{
throw
new
AssertionError
();
}
...
...
@@ -489,10 +478,6 @@ public class Type implements PrimitiveType {
return
new
WildcardType
(
t
,
kind
,
tsym
,
bound
);
}
public
Type
removeBounds
()
{
return
isUnbound
()
?
this
:
type
;
}
public
Type
getExtendsBound
()
{
if
(
kind
==
EXTENDS
)
return
type
;
...
...
src/share/classes/com/sun/tools/javac/code/Types.java
浏览文件 @
e5206d1f
...
...
@@ -709,16 +709,13 @@ public class Types {
case
UNDETVAR:
if
(
s
.
tag
==
WILDCARD
)
{
UndetVar
undetvar
=
(
UndetVar
)
t
;
// Because of wildcard capture, s must be on the left
// hand side of an assignment. Furthermore, t is an
// underconstrained type variable, for example, one
// that is only used in the return type of a method.
// If the type variable is truly underconstrained, it
// cannot have any low bounds:
assert
undetvar
.
lobounds
.
isEmpty
()
:
undetvar
;
undetvar
.
inst
=
glb
(
upperBound
(
s
),
undetvar
.
inst
);
// We should check instantiated type against any of the
// undetvar's lower bounds.
for
(
Type
t2
:
undetvar
.
lobounds
)
{
if
(!
isSubtype
(
t2
,
undetvar
.
inst
))
return
false
;
}
return
true
;
}
else
{
return
isSameType
(
t
,
s
);
...
...
@@ -3367,33 +3364,67 @@ public class Types {
* quantifiers) only
*/
private
Type
rewriteQuantifiers
(
Type
t
,
boolean
high
,
boolean
rewriteTypeVars
)
{
ListBuffer
<
Type
>
from
=
new
ListBuffer
<
Type
>();
ListBuffer
<
Type
>
to
=
new
ListBuffer
<
Type
>();
adaptSelf
(
t
,
from
,
to
);
ListBuffer
<
Type
>
rewritten
=
new
ListBuffer
<
Type
>();
List
<
Type
>
formals
=
from
.
toList
();
boolean
changed
=
false
;
for
(
Type
arg
:
to
.
toList
())
{
Type
bound
;
if
(
rewriteTypeVars
&&
arg
.
tag
==
TYPEVAR
)
{
TypeVar
tv
=
(
TypeVar
)
arg
;
bound
=
high
?
tv
.
bound
:
syms
.
botType
;
}
else
{
bound
=
high
?
upperBound
(
arg
)
:
lowerBound
(
arg
);
}
Type
newarg
=
bound
;
if
(
arg
!=
bound
)
{
changed
=
true
;
newarg
=
high
?
makeExtendsWildcard
(
bound
,
(
TypeVar
)
formals
.
head
)
return
new
Rewriter
(
high
,
rewriteTypeVars
).
rewrite
(
t
);
}
class
Rewriter
extends
UnaryVisitor
<
Type
>
{
boolean
high
;
boolean
rewriteTypeVars
;
Rewriter
(
boolean
high
,
boolean
rewriteTypeVars
)
{
this
.
high
=
high
;
this
.
rewriteTypeVars
=
rewriteTypeVars
;
}
Type
rewrite
(
Type
t
)
{
ListBuffer
<
Type
>
from
=
new
ListBuffer
<
Type
>();
ListBuffer
<
Type
>
to
=
new
ListBuffer
<
Type
>();
adaptSelf
(
t
,
from
,
to
);
ListBuffer
<
Type
>
rewritten
=
new
ListBuffer
<
Type
>();
List
<
Type
>
formals
=
from
.
toList
();
boolean
changed
=
false
;
for
(
Type
arg
:
to
.
toList
())
{
Type
bound
=
visit
(
arg
);
if
(
arg
!=
bound
)
{
changed
=
true
;
bound
=
high
?
makeExtendsWildcard
(
bound
,
(
TypeVar
)
formals
.
head
)
:
makeSuperWildcard
(
bound
,
(
TypeVar
)
formals
.
head
);
}
rewritten
.
append
(
bound
);
formals
=
formals
.
tail
;
}
rewritten
.
append
(
newarg
);
formals
=
formals
.
tail
;
if
(
changed
)
return
subst
(
t
.
tsym
.
type
,
from
.
toList
(),
rewritten
.
toList
());
else
return
t
;
}
public
Type
visitType
(
Type
t
,
Void
s
)
{
return
high
?
upperBound
(
t
)
:
lowerBound
(
t
);
}
@Override
public
Type
visitCapturedType
(
CapturedType
t
,
Void
s
)
{
return
visitWildcardType
(
t
.
wildcard
,
null
);
}
@Override
public
Type
visitTypeVar
(
TypeVar
t
,
Void
s
)
{
if
(
rewriteTypeVars
)
return
high
?
t
.
bound
:
syms
.
botType
;
else
return
t
;
}
@Override
public
Type
visitWildcardType
(
WildcardType
t
,
Void
s
)
{
Type
bound
=
high
?
t
.
getExtendsBound
()
:
t
.
getSuperBound
();
if
(
bound
==
null
)
bound
=
high
?
syms
.
objectType
:
syms
.
botType
;
return
bound
;
}
if
(
changed
)
return
subst
(
t
.
tsym
.
type
,
from
.
toList
(),
rewritten
.
toList
());
else
return
t
;
}
/**
...
...
src/share/classes/com/sun/tools/javac/comp/Attr.java
浏览文件 @
e5206d1f
...
...
@@ -2007,6 +2007,10 @@ public class Attr extends JCTree.Visitor {
log
.
error
(
pos
,
"type.var.cant.be.deref"
);
return
syms
.
errSymbol
;
}
else
{
Symbol
sym2
=
(
sym
.
flags
()
&
Flags
.
PRIVATE
)
!=
0
?
rs
.
new
AccessError
(
env
,
site
,
sym
)
:
sym
;
rs
.
access
(
sym2
,
pos
,
site
,
name
,
true
);
return
sym
;
}
case
ERROR:
...
...
@@ -2374,16 +2378,14 @@ public class Attr extends JCTree.Visitor {
}
if
(
warned
&&
sym
.
type
.
tag
==
FORALL
)
{
String
typeargs
=
""
;
if
(
typeargtypes
!=
null
&&
typeargtypes
.
nonEmpty
())
{
typeargs
=
"<"
+
Type
.
toString
(
typeargtypes
)
+
">"
;
}
chk
.
warnUnchecked
(
env
.
tree
.
pos
(),
"unchecked.meth.invocation.applied"
,
sym
,
sym
.
location
(),
typeargs
,
Type
.
toString
(
argtypes
));
kindName
(
sym
),
sym
.
name
,
rs
.
methodArguments
(
sym
.
type
.
getParameterTypes
()),
rs
.
methodArguments
(
argtypes
),
kindName
(
sym
.
location
()),
sym
.
location
());
owntype
=
new
MethodType
(
owntype
.
getParameterTypes
(),
types
.
erasure
(
owntype
.
getReturnType
()),
owntype
.
getThrownTypes
(),
...
...
@@ -2516,7 +2518,10 @@ public class Attr extends JCTree.Visitor {
// accept class or interface or typevar as first bound.
Type
b
=
checkBase
(
bs
.
head
,
tree
.
bounds
.
head
,
env
,
false
,
false
,
false
);
boundSet
.
add
(
types
.
erasure
(
b
));
if
(
b
.
tag
==
TYPEVAR
)
{
if
(
b
.
isErroneous
())
{
a
.
bound
=
b
;
}
else
if
(
b
.
tag
==
TYPEVAR
)
{
// if first bound was a typevar, do not accept further bounds.
if
(
tree
.
bounds
.
tail
.
nonEmpty
())
{
log
.
error
(
tree
.
bounds
.
tail
.
head
.
pos
(),
...
...
@@ -2530,7 +2535,9 @@ public class Attr extends JCTree.Visitor {
for
(
JCExpression
bound
:
tree
.
bounds
.
tail
)
{
bs
=
bs
.
tail
;
Type
i
=
checkBase
(
bs
.
head
,
bound
,
env
,
false
,
true
,
false
);
if
(
i
.
tag
==
CLASS
)
if
(
i
.
isErroneous
())
a
.
bound
=
i
;
else
if
(
i
.
tag
==
CLASS
)
chk
.
checkNotRepeated
(
bound
.
pos
(),
types
.
erasure
(
i
),
boundSet
);
}
}
...
...
src/share/classes/com/sun/tools/javac/comp/Check.java
浏览文件 @
e5206d1f
...
...
@@ -424,43 +424,43 @@ public class Check {
* @param bs The bound.
*/
private
void
checkExtends
(
DiagnosticPosition
pos
,
Type
a
,
TypeVar
bs
)
{
if
(
a
.
tag
==
TYPEVAR
&&
((
TypeVar
)
a
).
isCaptured
())
{
CapturedType
ct
=
(
CapturedType
)
a
;
boolean
ok
;
if
(
ct
.
bound
.
isErroneous
())
{
//capture doesn't exist
ok
=
false
;
}
else
{
switch
(
ct
.
wildcard
.
kind
)
{
case
EXTENDS:
ok
=
types
.
isCastable
(
bs
.
getUpperBound
(),
types
.
upperBound
(
a
),
Warner
.
noWarnings
);
break
;
case
SUPER:
ok
=
!
types
.
notSoftSubtype
(
types
.
lowerBound
(
a
),
bs
.
getUpperBound
());
break
;
case
UNBOUND:
ok
=
true
;
break
;
default
:
throw
new
AssertionError
(
"Invalid bound kind"
);
}
}
if
(!
ok
)
log
.
error
(
pos
,
"not.within.bounds"
,
a
);
}
else
{
a
=
types
.
upperBound
(
a
);
for
(
List
<
Type
>
l
=
types
.
getBounds
(
bs
);
l
.
nonEmpty
();
l
=
l
.
tail
)
{
if
(!
types
.
isSubtype
(
a
,
l
.
head
))
{
log
.
error
(
pos
,
"not.within.bounds"
,
a
);
return
;
}
if
(
a
.
isUnbound
())
{
return
;
}
else
if
(
a
.
tag
!=
WILDCARD
)
{
a
=
types
.
upperBound
(
a
);
for
(
List
<
Type
>
l
=
types
.
getBounds
(
bs
);
l
.
nonEmpty
();
l
=
l
.
tail
)
{
if
(!
types
.
isSubtype
(
a
,
l
.
head
))
{
log
.
error
(
pos
,
"not.within.bounds"
,
a
);
return
;
}
}
}
else
if
(
a
.
isExtendsBound
())
{
if
(!
types
.
isCastable
(
bs
.
getUpperBound
(),
types
.
upperBound
(
a
),
Warner
.
noWarnings
))
log
.
error
(
pos
,
"not.within.bounds"
,
a
);
}
else
if
(
a
.
isSuperBound
())
{
if
(
types
.
notSoftSubtype
(
types
.
lowerBound
(
a
),
bs
.
getUpperBound
()))
log
.
error
(
pos
,
"not.within.bounds"
,
a
);
}
}
/** Check that a type is within some bounds.
*
* Used in TypeApply to verify that, e.g., X in V<X> is a valid
* type argument.
* @param pos Position to be used for error reporting.
* @param a The type that should be bounded by bs.
* @param bs The bound.
*/
private
void
checkCapture
(
JCTypeApply
tree
)
{
List
<
JCExpression
>
args
=
tree
.
getTypeArguments
();
for
(
Type
arg
:
types
.
capture
(
tree
.
type
).
getTypeArguments
())
{
if
(
arg
.
tag
==
TYPEVAR
&&
arg
.
getUpperBound
().
isErroneous
())
{
log
.
error
(
args
.
head
.
pos
,
"not.within.bounds"
,
args
.
head
.
type
);
break
;
}
args
=
args
.
tail
;
}
}
}
/** Check that type is different from 'void'.
* @param pos Position to be used for error reporting.
...
...
@@ -802,10 +802,10 @@ public class Check {
public
void
visitTypeApply
(
JCTypeApply
tree
)
{
if
(
tree
.
type
.
tag
==
CLASS
)
{
List
<
Type
>
formals
=
tree
.
type
.
tsym
.
type
.
getTypeArgument
s
();
List
<
Type
>
actuals
=
t
ypes
.
capture
(
tree
.
type
).
getTypeArgument
s
();
List
<
Type
>
formals
=
tree
.
type
.
tsym
.
type
.
allparam
s
();
List
<
Type
>
actuals
=
t
ree
.
type
.
allparam
s
();
List
<
JCExpression
>
args
=
tree
.
arguments
;
List
<
Type
>
forms
=
formals
;
List
<
Type
>
forms
=
tree
.
type
.
tsym
.
type
.
getTypeArguments
()
;
ListBuffer
<
TypeVar
>
tvars_buf
=
new
ListBuffer
<
TypeVar
>();
// For matching pairs of actual argument types `a' and
...
...
@@ -826,25 +826,29 @@ public class Check {
}
args
=
tree
.
arguments
;
List
<
TypeVar
>
tvars
=
tvars_buf
.
toList
();
while
(
args
.
nonEmpty
()
&&
tvars
.
nonEmpty
())
{
List
<
Type
>
tvars_cap
=
types
.
substBounds
(
formals
,
formals
,
types
.
capture
(
tree
.
type
).
allparams
());
while
(
args
.
nonEmpty
()
&&
tvars_cap
.
nonEmpty
())
{
// Let the actual arguments know their bound
args
.
head
.
type
.
withTypeVar
(
tvars
.
head
);
args
.
head
.
type
.
withTypeVar
(
(
TypeVar
)
tvars_cap
.
head
);
args
=
args
.
tail
;
tvars
=
tvars
.
tail
;
tvars
_cap
=
tvars_cap
.
tail
;
}
args
=
tree
.
arguments
;
tvars
=
tvars_buf
.
toList
();
List
<
TypeVar
>
tvars
=
tvars_buf
.
toList
();
while
(
args
.
nonEmpty
()
&&
tvars
.
nonEmpty
())
{
checkExtends
(
args
.
head
.
pos
(),
a
ctuals
.
head
,
a
rgs
.
head
.
type
,
tvars
.
head
);
args
=
args
.
tail
;
tvars
=
tvars
.
tail
;
actuals
=
actuals
.
tail
;
}
checkCapture
(
tree
);
// Check that this type is either fully parameterized, or
// not parameterized at all.
if
(
tree
.
type
.
getEnclosingType
().
isRaw
())
...
...
src/share/classes/com/sun/tools/javac/comp/Resolve.java
浏览文件 @
e5206d1f
...
...
@@ -30,6 +30,8 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
import
com.sun.tools.javac.code.*
;
import
com.sun.tools.javac.jvm.*
;
import
com.sun.tools.javac.tree.*
;
import
com.sun.tools.javac.api.Formattable.LocalizedString
;
import
static
com
.
sun
.
tools
.
javac
.
comp
.
Resolve
.
MethodResolutionPhase
.*;
import
com.sun.tools.javac.code.Type.*
;
import
com.sun.tools.javac.code.Symbol.*
;
...
...
@@ -40,6 +42,9 @@ import static com.sun.tools.javac.code.Kinds.*;
import
static
com
.
sun
.
tools
.
javac
.
code
.
TypeTags
.*;
import
javax.lang.model.element.ElementVisitor
;
import
java.util.Map
;
import
java.util.HashMap
;
/** Helper class for name resolution, used mostly by the attribution phase.
*
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
...
...
@@ -554,7 +559,6 @@ public class Resolve {
boolean
useVarargs
,
boolean
operator
)
{
if
(
sym
.
kind
==
ERR
)
return
bestSoFar
;
if
(!
sym
.
isInheritedIn
(
site
.
tsym
,
types
))
return
bestSoFar
;
assert
sym
.
kind
<
AMBIGUOUS
;
try
{
if
(
rawInstantiate
(
env
,
site
,
sym
,
argtypes
,
typeargtypes
,
...
...
@@ -651,8 +655,9 @@ public class Resolve {
// both abstract or both concrete
if
(!
m1Abstract
&&
!
m2Abstract
)
return
new
AmbiguityError
(
m1
,
m2
);
// check for same erasure
if
(!
types
.
isSameType
(
m1
.
erasure
(
types
),
m2
.
erasure
(
types
)))
// check that both signatures have the same erasure
if
(!
types
.
isSameTypes
(
m1
.
erasure
(
types
).
getParameterTypes
(),
m2
.
erasure
(
types
).
getParameterTypes
()))
return
new
AmbiguityError
(
m1
,
m2
);
// both abstract, neither overridden; merge throws clause and result type
Symbol
result
;
...
...
@@ -1192,15 +1197,23 @@ public class Resolve {
Name
name
,
List
<
Type
>
argtypes
,
List
<
Type
>
typeargtypes
)
{
Symbol
sym
=
findFun
(
env
,
name
,
argtypes
,
typeargtypes
,
false
,
env
.
info
.
varArgs
=
false
);
if
(
varargsEnabled
&&
sym
.
kind
>=
WRONG_MTHS
)
{
sym
=
findFun
(
env
,
name
,
argtypes
,
typeargtypes
,
true
,
false
);
if
(
sym
.
kind
>=
WRONG_MTHS
)
sym
=
findFun
(
env
,
name
,
argtypes
,
typeargtypes
,
true
,
env
.
info
.
varArgs
=
true
);
Symbol
sym
=
methodNotFound
;
List
<
MethodResolutionPhase
>
steps
=
methodResolutionSteps
;
while
(
steps
.
nonEmpty
()
&&
steps
.
head
.
isApplicable
(
boxingEnabled
,
varargsEnabled
)
&&
sym
.
kind
>=
ERRONEOUS
)
{
sym
=
findFun
(
env
,
name
,
argtypes
,
typeargtypes
,
steps
.
head
.
isBoxingRequired
,
env
.
info
.
varArgs
=
steps
.
head
.
isVarargsRequired
);
methodResolutionCache
.
put
(
steps
.
head
,
sym
);
steps
=
steps
.
tail
;
}
if
(
sym
.
kind
>=
AMBIGUOUS
)
{
sym
=
access
(
sym
,
pos
,
env
.
enclClass
.
sym
.
type
,
name
,
false
,
argtypes
,
typeargtypes
);
if
(
sym
.
kind
>=
AMBIGUOUS
)
{
//if nothing is found return the 'first' error
MethodResolutionPhase
errPhase
=
firstErroneousResolutionPhase
();
sym
=
access
(
methodResolutionCache
.
get
(
errPhase
),
pos
,
env
.
enclClass
.
sym
.
type
,
name
,
false
,
argtypes
,
typeargtypes
);
env
.
info
.
varArgs
=
errPhase
.
isVarargsRequired
;
}
return
sym
;
}
...
...
@@ -1217,17 +1230,23 @@ public class Resolve {
Symbol
resolveQualifiedMethod
(
DiagnosticPosition
pos
,
Env
<
AttrContext
>
env
,
Type
site
,
Name
name
,
List
<
Type
>
argtypes
,
List
<
Type
>
typeargtypes
)
{
Symbol
sym
=
findMethod
(
env
,
site
,
name
,
argtypes
,
typeargtypes
,
false
,
env
.
info
.
varArgs
=
false
,
false
);
if
(
varargsEnabled
&&
sym
.
kind
>=
WRONG_MTHS
)
{
sym
=
findMethod
(
env
,
site
,
name
,
argtypes
,
typeargtypes
,
true
,
false
,
false
);
if
(
sym
.
kind
>=
WRONG_MTHS
)
sym
=
findMethod
(
env
,
site
,
name
,
argtypes
,
typeargtypes
,
true
,
env
.
info
.
varArgs
=
true
,
false
);
Symbol
sym
=
methodNotFound
;
List
<
MethodResolutionPhase
>
steps
=
methodResolutionSteps
;
while
(
steps
.
nonEmpty
()
&&
steps
.
head
.
isApplicable
(
boxingEnabled
,
varargsEnabled
)
&&
sym
.
kind
>=
ERRONEOUS
)
{
sym
=
findMethod
(
env
,
site
,
name
,
argtypes
,
typeargtypes
,
steps
.
head
.
isBoxingRequired
(),
env
.
info
.
varArgs
=
steps
.
head
.
isVarargsRequired
(),
false
);
methodResolutionCache
.
put
(
steps
.
head
,
sym
);
steps
=
steps
.
tail
;
}
if
(
sym
.
kind
>=
AMBIGUOUS
)
{
sym
=
access
(
sym
,
pos
,
site
,
name
,
true
,
argtypes
,
typeargtypes
);
if
(
sym
.
kind
>=
AMBIGUOUS
)
{
//if nothing is found return the 'first' error
MethodResolutionPhase
errPhase
=
firstErroneousResolutionPhase
();
sym
=
access
(
methodResolutionCache
.
get
(
errPhase
),
pos
,
site
,
name
,
true
,
argtypes
,
typeargtypes
);
env
.
info
.
varArgs
=
errPhase
.
isVarargsRequired
;
}
return
sym
;
}
...
...
@@ -1268,14 +1287,22 @@ public class Resolve {
Type
site
,
List
<
Type
>
argtypes
,
List
<
Type
>
typeargtypes
)
{
Symbol
sym
=
resolveConstructor
(
pos
,
env
,
site
,
argtypes
,
typeargtypes
,
false
,
env
.
info
.
varArgs
=
false
);
if
(
varargsEnabled
&&
sym
.
kind
>=
WRONG_MTHS
)
{
sym
=
resolveConstructor
(
pos
,
env
,
site
,
argtypes
,
typeargtypes
,
true
,
false
);
if
(
sym
.
kind
>=
WRONG_MTHS
)
sym
=
resolveConstructor
(
pos
,
env
,
site
,
argtypes
,
typeargtypes
,
true
,
env
.
info
.
varArgs
=
true
);
Symbol
sym
=
methodNotFound
;
List
<
MethodResolutionPhase
>
steps
=
methodResolutionSteps
;
while
(
steps
.
nonEmpty
()
&&
steps
.
head
.
isApplicable
(
boxingEnabled
,
varargsEnabled
)
&&
sym
.
kind
>=
ERRONEOUS
)
{
sym
=
resolveConstructor
(
pos
,
env
,
site
,
argtypes
,
typeargtypes
,
steps
.
head
.
isBoxingRequired
(),
env
.
info
.
varArgs
=
steps
.
head
.
isVarargsRequired
());
methodResolutionCache
.
put
(
steps
.
head
,
sym
);
steps
=
steps
.
tail
;
}
if
(
sym
.
kind
>=
AMBIGUOUS
)
{
sym
=
access
(
sym
,
pos
,
site
,
names
.
init
,
true
,
argtypes
,
typeargtypes
);
if
(
sym
.
kind
>=
AMBIGUOUS
)
{
//if nothing is found return the 'first' error
MethodResolutionPhase
errPhase
=
firstErroneousResolutionPhase
();
sym
=
access
(
methodResolutionCache
.
get
(
errPhase
),
pos
,
site
,
names
.
init
,
true
,
argtypes
,
typeargtypes
);
env
.
info
.
varArgs
=
errPhase
.
isVarargsRequired
();
}
return
sym
;
}
...
...
@@ -1452,6 +1479,12 @@ public class Resolve {
error
.
report
(
log
,
tree
.
pos
(),
type
.
getEnclosingType
(),
null
,
null
,
null
);
}
private
final
LocalizedString
noArgs
=
new
LocalizedString
(
"compiler.misc.no.args"
);
public
Object
methodArguments
(
List
<
Type
>
argtypes
)
{
return
argtypes
.
isEmpty
()
?
noArgs
:
argtypes
;
}
/** Root class for resolve errors.
* Instances of this class indicate "Symbol not found".
* Instances of subclass indicate other errors.
...
...
@@ -1558,8 +1591,8 @@ public class Resolve {
"cant.apply.symbol"
+
(
explanation
!=
null
?
".1"
:
""
),
kindname
,
ws
.
name
==
names
.
init
?
ws
.
owner
.
name
:
ws
.
name
,
ws
.
type
.
getParameterTypes
(
),
argtypes
,
methodArguments
(
ws
.
type
.
getParameterTypes
()
),
methodArguments
(
argtypes
)
,
kindName
(
ws
.
owner
),
ws
.
owner
.
type
,
explanation
);
...
...
@@ -1733,4 +1766,50 @@ public class Resolve {
pair
.
sym2
.
location
(
site
,
types
));
}
}
enum
MethodResolutionPhase
{
BASIC
(
false
,
false
),
BOX
(
true
,
false
),
VARARITY
(
true
,
true
);
boolean
isBoxingRequired
;
boolean
isVarargsRequired
;
MethodResolutionPhase
(
boolean
isBoxingRequired
,
boolean
isVarargsRequired
)
{
this
.
isBoxingRequired
=
isBoxingRequired
;
this
.
isVarargsRequired
=
isVarargsRequired
;
}
public
boolean
isBoxingRequired
()
{
return
isBoxingRequired
;
}
public
boolean
isVarargsRequired
()
{
return
isVarargsRequired
;
}
public
boolean
isApplicable
(
boolean
boxingEnabled
,
boolean
varargsEnabled
)
{
return
(
varargsEnabled
||
!
isVarargsRequired
)
&&
(
boxingEnabled
||
!
isBoxingRequired
);
}
}
private
Map
<
MethodResolutionPhase
,
Symbol
>
methodResolutionCache
=
new
HashMap
<
MethodResolutionPhase
,
Symbol
>(
MethodResolutionPhase
.
values
().
length
);
final
List
<
MethodResolutionPhase
>
methodResolutionSteps
=
List
.
of
(
BASIC
,
BOX
,
VARARITY
);
private
MethodResolutionPhase
firstErroneousResolutionPhase
()
{
MethodResolutionPhase
bestSoFar
=
BASIC
;
Symbol
sym
=
methodNotFound
;
List
<
MethodResolutionPhase
>
steps
=
methodResolutionSteps
;
while
(
steps
.
nonEmpty
()
&&
steps
.
head
.
isApplicable
(
boxingEnabled
,
varargsEnabled
)
&&
sym
.
kind
>=
WRONG_MTHS
)
{
sym
=
methodResolutionCache
.
get
(
steps
.
head
);
bestSoFar
=
steps
.
head
;
steps
=
steps
.
tail
;
}
return
bestSoFar
;
}
}
src/share/classes/com/sun/tools/javac/resources/compiler.properties
浏览文件 @
e5206d1f
...
...
@@ -745,7 +745,10 @@ compiler.warn.unchecked.call.mbr.of.raw.type=\
compiler.warn.unchecked.cast.to.type
=
\
[unchecked] unchecked cast to type {0}
compiler.warn.unchecked.meth.invocation.applied
=
\
[unchecked] unchecked method invocation: {0} in {1} is applied to {2}({3})
[unchecked] unchecked method invocation: {0} {1} in {4} {5} is applied to given types
\n\
required: {2}
\n\
found: {3}
compiler.warn.unchecked.generic.array.creation
=
\
[unchecked] unchecked generic array creation of type {0} for varargs parameter
...
...
@@ -1062,6 +1065,9 @@ compiler.misc.kindname.package=\
package
#####
compiler.misc.no.args
=
\
no arguments
compiler.err.override.static
=
\
{0}; overriding method is static
compiler.err.override.meth
=
\
...
...
test/tools/javac/6758789/T6758789a.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6758789
* @summary 6758789: Some method resolution diagnostic should be improved
* @author Maurizio Cimadamore
*
* @compile/fail/ref=T6758789a.out -XDrawDiagnostics T6758789a.java
*/
class
T6758789a
{
void
m1
()
{}
void
m2
(
int
i
)
{}
void
test
()
{
m1
(
1
);
m2
();
}
}
test/tools/javac/6758789/T6758789a.out
0 → 100644
浏览文件 @
e5206d1f
T6758789a.java:37:9: compiler.err.cant.apply.symbol: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, null
T6758789a.java:38:9: compiler.err.cant.apply.symbol: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, null
2 errors
\ No newline at end of file
test/tools/javac/6758789/T6758789b.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6758789
* @summary 6758789: Some method resolution diagnostic should be improved
* @author Maurizio Cimadamore
*
* @compile/fail/ref=T6758789b.out -Werror -XDrawDiagnostics -Xlint:unchecked T6758789b.java
*/
class
T6758789a
{
class
Foo
<
T
>
{}
<
X
>
void
m
(
Foo
<
X
>
foo
)
{}
void
test
()
{
m
(
new
Foo
());
}
}
test/tools/javac/6758789/T6758789b.out
0 → 100644
浏览文件 @
e5206d1f
T6758789b.java:39:11: compiler.warn.prob.found.req: (- compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<X>
T6758789b.java:39:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo<X>, T6758789a.Foo, kindname.class, T6758789a
2 warnings
test/tools/javac/cast/6548436/T6548436a.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6548436
* @summary Incorrect inconvertible types error
* @author Maurizio Cimadamore
*
* @compile T6548436a.java
*/
public
class
T6548436a
{
static
class
Base
<
E
extends
Comparable
<
E
>>
{}
static
void
test
(
Base
<?>
je
)
{
Object
o
=
(
Base
<
Integer
>)
je
;
}
}
test/tools/javac/cast/6548436/T6548436b.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6548436
* @summary Incorrect inconvertible types error
* @author Maurizio Cimadamore
*
* @compile T6548436b.java
*/
public
class
T6548436b
{
enum
E
{
}
static
void
test
(
Enum
<?>
o
)
{
Object
e
=
(
E
)
o
;
}
}
test/tools/javac/cast/6548436/T6548436c.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6548436
* @summary Incorrect inconvertible types error
* @author Maurizio Cimadamore
*
* @compile T6548436c.java
*/
public
class
T6548436c
{
interface
A
<
T
extends
A
<?
super
T
>>
{
}
interface
B
extends
A
<
B
>
{
}
static
void
test
(
A
<?>
a
)
{
Object
o
=
(
B
)
a
;
}
}
test/tools/javac/cast/6548436/T6548436d.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6548436
* @summary Incorrect inconvertible types error
* @author Maurizio Cimadamore
*
* @compile/fail T6548436d.java
*/
public
class
T6548436d
{
static
class
Base
<
E
extends
Comparable
<
E
>>
{}
static
void
test
(
Base
<?
extends
Double
>
je
)
{
Object
o
=
(
Base
<
Integer
>)
je
;
}
}
\ No newline at end of file
test/tools/javac/generics/6487370/T6487370.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6487370
* @author Maurizio Cimadamore
* @summary javac incorrectly gives ambiguity warning with override-equivalent abstract inherited methods
*/
public
class
T6487370
{
interface
I1
{
String
m
(
Number
n
);
}
interface
I2
{
Object
m
(
Number
n
);
}
static
abstract
class
X
implements
I1
,
I2
{
String
test
()
{
return
m
(
0.0f
);
}
}
static
class
W
extends
X
{
public
String
m
(
Number
n
)
{
return
"Hello!"
;
}
}
public
static
void
main
(
String
args
[])
{
System
.
out
.
println
(
new
W
().
test
());
}
}
test/tools/javac/generics/6531090/T6531090b.java
浏览文件 @
e5206d1f
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 6531090
* @bug 6531090
6711619
*
* @summary Cannot access methods/fields of a captured type belonging to an intersection type
* @author Maurizio Cimadamore
...
...
@@ -32,12 +32,20 @@
public
class
T6531090b
{
static
class
A
{
public
void
a
()
{}
public
A
a
;
public
void
a1
()
{}
protected
void
a2
()
{}
void
a3
()
{}
public
A
a1
;
protected
A
a2
;
A
a3
;
}
static
class
B
extends
A
{
public
void
b
(){}
public
B
b
;
public
void
b1
()
{}
protected
void
b2
()
{}
void
b3
()
{}
public
B
b1
;
protected
B
b2
;
B
b3
;
}
static
interface
I
{
void
i
();
...
...
@@ -65,18 +73,35 @@ public class T6531090b {
}
static
void
testMemberMethods
(
C
<?
extends
A
,
?
extends
I
>
arg
)
{
arg
.
t
.
a
();
arg
.
t
.
b
();
arg
.
t
.
a1
();
arg
.
t
.
a2
();
arg
.
t
.
a3
();
arg
.
t
.
b1
();
arg
.
t
.
b2
();
arg
.
t
.
b3
();
arg
.
t
.
i1
();
arg
.
w
.
a
();
arg
.
w
.
b
();
arg
.
w
.
a1
();
arg
.
w
.
a2
();
arg
.
w
.
a3
();
arg
.
w
.
b1
();
arg
.
w
.
b2
();
arg
.
w
.
b3
();
arg
.
w
.
i1
();
}
static
void
testMemberFields
(
C
<?
extends
A
,
?
extends
I
>
arg
)
{
A
ta
=
arg
.
t
.
a
;
B
tb
=
arg
.
t
.
b
;
A
wa
=
arg
.
w
.
a
;
B
wb
=
arg
.
w
.
b
;
A
ta
;
B
tb
;
ta
=
arg
.
t
.
a1
;
ta
=
arg
.
t
.
a2
;
ta
=
arg
.
t
.
a3
;
tb
=
arg
.
t
.
b1
;
tb
=
arg
.
t
.
b2
;
tb
=
arg
.
t
.
b3
;
ta
=
arg
.
w
.
a1
;
ta
=
arg
.
w
.
a2
;
ta
=
arg
.
w
.
a3
;
tb
=
arg
.
w
.
b1
;
tb
=
arg
.
w
.
b2
;
tb
=
arg
.
w
.
b3
;
}
}
test/tools/javac/generics/6711619/T6711619a.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6711619
*
* @summary javac doesn't allow access to protected members in intersection types
* @author Maurizio Cimadamore
*
* @compile/fail/ref=T6711619a.out -XDrawDiagnostics T6711619a.java
*/
class
T6711619a
{
static
class
A
{
private
void
a
()
{}
private
A
a
;
}
static
class
B
extends
A
{
private
B
b
()
{}
private
B
b
;
}
static
interface
I
{
void
i
();
}
static
interface
I1
{
void
i1
();
}
static
class
E
extends
B
implements
I
,
I1
{
public
void
i
()
{}
public
void
i1
()
{}
}
static
class
C
<
W
extends
B
&
I1
,
T
extends
W
>{
T
t
;
W
w
;
C
(
W
w
,
T
t
)
{
this
.
w
=
w
;
this
.
t
=
t
;
}
}
static
void
testMemberMethods
(
C
<?
extends
A
,
?
extends
I
>
arg
)
{
arg
.
t
.
a
();
arg
.
t
.
b
();
}
static
void
testMemberFields
(
C
<?
extends
A
,
?
extends
I
>
arg
)
{
A
ta
;
B
tb
;
ta
=
arg
.
t
.
a
;
tb
=
arg
.
t
.
b
;
ta
=
arg
.
w
.
a
;
tb
=
arg
.
w
.
b
;
}
}
\ No newline at end of file
test/tools/javac/generics/6711619/T6711619a.out
0 → 100644
浏览文件 @
e5206d1f
T6711619a.java:63:14: compiler.err.report.access: a(), private, T6711619a.A
T6711619a.java:64:14: compiler.err.report.access: b(), private, T6711619a.B
T6711619a.java:69:19: compiler.err.report.access: a, private, T6711619a.A
T6711619a.java:70:19: compiler.err.report.access: b, private, T6711619a.B
T6711619a.java:71:19: compiler.err.report.access: a, private, T6711619a.A
T6711619a.java:72:19: compiler.err.report.access: b, private, T6711619a.B
6 errors
test/tools/javac/generics/6711619/T6711619b.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6711619
*
* @summary javac doesn't allow access to protected members in intersection types
* @author Maurizio Cimadamore
*
* @compile/fail/ref=T6711619b.out -XDrawDiagnostics T6711619b.java
*/
class
T6711619b
{
static
class
X1
<
E
extends
X1
<
E
>>
{
private
int
i
;
E
e
;
int
f
()
{
return
e
.
i
;
}
}
static
class
X2
<
E
extends
X2
<
E
>>
{
static
private
int
i
;
int
f
()
{
return
E
.
i
;
}
}
static
class
X3
<
E
extends
X3
<
E
>
&
java
.
io
.
Serializable
>
{
private
int
i
;
E
e
;
int
f
()
{
return
e
.
i
;
}
}
static
class
X4
<
E
extends
X4
<
E
>
&
java
.
io
.
Serializable
>
{
static
private
int
i
;
int
f
()
{
return
E
.
i
;
}
}
}
\ No newline at end of file
test/tools/javac/generics/6711619/T6711619b.out
0 → 100644
浏览文件 @
e5206d1f
T6711619b.java:39:22: compiler.err.report.access: i, private, T6711619b.X1
T6711619b.java:46:22: compiler.err.report.access: i, private, T6711619b.X2
T6711619b.java:54:22: compiler.err.report.access: i, private, T6711619b.X3
T6711619b.java:61:22: compiler.err.report.access: i, private, T6711619b.X4
4 errors
test/tools/javac/generics/T6557954.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6557954
* @summary Inner class type parameters doesn't get substituted when checking type well-formedness
* @author Maurizio Cimadamore
*
* @compile T6557954.java
*/
class
T6557954
<
T
>
{
class
Foo
<
U
extends
T
>
{}
T6557954
<
Number
>.
Foo
<
Integer
>
f
;
}
\ No newline at end of file
test/tools/javac/generics/inference/6718364/T6718364.out
浏览文件 @
e5206d1f
T6718364.java:36:32: compiler.warn.prob.found.req: (- compiler.misc.unchecked.assign), T6718364.X, T6718364.X<java.lang.Integer>
T6718364.java:36:10: compiler.warn.unchecked.meth.invocation.applied:
<T>m(T6718364.X<T>,T), T6718364, , T6718364.X<T6718364.X<java.lang.Integer>>,T6718364.X
T6718364.java:36:10: compiler.warn.unchecked.meth.invocation.applied:
kindname.method, m, T6718364.X<T>,T, T6718364.X<T6718364.X<java.lang.Integer>>,T6718364.X, kindname.class, T6718364
2 warnings
\ No newline at end of file
test/tools/javac/generics/typevars/6680106/T6680106.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6680106
* @summary StackOverFlowError for Cyclic inheritance in TypeParameters with ArrayType Bounds
* @author Maurizio Cimadamore
* @compile/fail/ref=T6680106.out -XDrawDiagnostics T6680106.java
*/
class
T6680106
{
class
A0
{}
class
A1
<
T
extends
T
[]>
{}
class
A2
<
T
extends
S
[],
S
extends
T
[]>
{}
class
A3
<
T
extends
S
[],
S
extends
U
[],
U
extends
T
[]>
{}
class
A5
<
T
extends
A0
&
T
[]>
{}
class
A6
<
T
extends
A0
&
S
[],
S
extends
A0
&
T
[]>
{}
class
A7
<
T
extends
A0
&
S
[],
S
extends
A0
&
U
[],
U
extends
A0
&
T
[]>
{}
}
test/tools/javac/generics/typevars/6680106/T6680106.out
0 → 100644
浏览文件 @
e5206d1f
T6680106.java:34:25: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
T6680106.java:35:25: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
T6680106.java:35:40: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
T6680106.java:36:25: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
T6680106.java:36:40: compiler.err.type.found.req: U[], (- compiler.misc.type.req.class)
T6680106.java:36:55: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
T6680106.java:37:30: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
T6680106.java:38:30: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
T6680106.java:38:50: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
T6680106.java:39:30: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
T6680106.java:39:50: compiler.err.type.found.req: U[], (- compiler.misc.type.req.class)
T6680106.java:39:70: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
12 errors
\ No newline at end of file
test/tools/javac/generics/wildcards/6
651719/T6651719b
.java
→
test/tools/javac/generics/wildcards/6
762569/T6762569a
.java
浏览文件 @
e5206d1f
...
...
@@ -23,14 +23,15 @@
/*
* @test
* @bug 6
65171
9
* @summary
Compiler crashes possibly during forward reference of TypeParameter
* @compile T6
651719b
.java
* @bug 6
76256
9
* @summary
Javac crashes with AssertionError in Types.containedBy
* @compile T6
762569a
.java
*/
import
java.util.*
;
public
class
T6651719b
{
class
T6762569a
{
<
T
>
void
m
(
T
t
,
List
<?
super
List
<
T
>>
list
)
{}
void
test
(
List
<?
super
List
<?>>
list
)
{
m
(
""
,
list
);
}
...
...
test/tools/javac/generics/wildcards/6762569/T6762569b.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6762569
* @summary Javac crashes with AssertionError in Types.containedBy
* @compile/fail T6762569b.java
*/
import
java.util.*
;
class
T6762569b
{
<
T
>
void
m
(
T
t
,
List
<?
super
List
<
T
>>
list
)
{}
void
test
(
List
<?
super
List
<?
extends
Number
>>
list
)
{
m
(
""
,
list
);
}
}
test/tools/javac/generics/wildcards/T6732484.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6732484
* @summary Bound error on wildcard code
* @author Maurizio Cimadamore
* @compile T6732484.java
*/
class
T6732484
{
class
A
<
T
extends
A
<
T
>>
{}
class
B
extends
A
<
B
>
{}
A
<?
super
B
>
f
;
}
\ No newline at end of file
test/tools/javac/varargs/T6746184.java
0 → 100644
浏览文件 @
e5206d1f
/*
* Copyright 2008 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 6746184
* @summary javac fails to compile call to public varargs method
*/
public
class
T6746184
{
public
static
void
main
(
String
[]
args
)
{
A
.
m
(
new
Object
());
}
}
class
A
{
public
static
void
m
(
final
Object
...
varargs
)
{}
private
static
void
m
(
final
Object
singleArg
)
{}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录