Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
aa1f2dfd
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看板
提交
aa1f2dfd
编写于
12月 04, 2014
作者:
A
asaha
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
32347a78
fd754805
变更
33
展开全部
隐藏空白更改
内联
并排
Showing
33 changed file
with
3246 addition
and
283 deletion
+3246
-283
.hgtags
.hgtags
+1
-0
src/share/classes/com/sun/tools/javac/comp/Attr.java
src/share/classes/com/sun/tools/javac/comp/Attr.java
+16
-10
src/share/classes/com/sun/tools/javac/comp/Flow.java
src/share/classes/com/sun/tools/javac/comp/Flow.java
+7
-1
src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
...hare/classes/com/sun/tools/javac/comp/LambdaToMethod.java
+199
-245
src/share/classes/com/sun/tools/javac/comp/Lower.java
src/share/classes/com/sun/tools/javac/comp/Lower.java
+16
-2
src/share/classes/com/sun/tools/javac/comp/Resolve.java
src/share/classes/com/sun/tools/javac/comp/Resolve.java
+1
-1
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
+23
-20
test/lib/annotations/annotations/classfile/ClassfileInspector.java
...annotations/annotations/classfile/ClassfileInspector.java
+1733
-0
test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.java
test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.java
+17
-0
test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.out
test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.out
+2
-0
test/tools/javac/T8019486/WrongLNTForLambdaTest.java
test/tools/javac/T8019486/WrongLNTForLambdaTest.java
+1
-1
test/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.java
...ols/javac/T8059921/ForbidAccessToFieldUsingSuperTest.java
+31
-0
test/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.out
...ools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.out
+3
-0
test/tools/javac/annotations/SyntheticParameters.java
test/tools/javac/annotations/SyntheticParameters.java
+198
-0
test/tools/javac/annotations/typeAnnotations/classfile/SyntheticParameters.java
...ations/typeAnnotations/classfile/SyntheticParameters.java
+133
-0
test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
...otations/typeAnnotations/referenceinfos/Constructors.java
+3
-3
test/tools/javac/flow/T8062747.java
test/tools/javac/flow/T8062747.java
+24
-0
test/tools/javac/lambda/T8057794.java
test/tools/javac/lambda/T8057794.java
+12
-0
test/tools/javac/lambda/T8057794.out
test/tools/javac/lambda/T8057794.out
+2
-0
test/tools/javac/lambda/methodReference/MethodRef8.java
test/tools/javac/lambda/methodReference/MethodRef8.java
+43
-0
test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java
...ac/lambda/methodReference/MethodRefNewInnerBootstrap.java
+72
-0
test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java
...lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java
+48
-0
test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java
...lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java
+57
-0
test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java
...bda/methodReference/MethodRefNewInnerInLambdaVerify1.java
+48
-0
test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java
...bda/methodReference/MethodRefNewInnerInLambdaVerify2.java
+62
-0
test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java
...thodReference/MethodRefNewInnerInLambdaVerify2simple.java
+50
-0
test/tools/javac/lambda/methodReference/MethodRefQualifier1.java
...ols/javac/lambda/methodReference/MethodRefQualifier1.java
+62
-0
test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java
.../lambda/methodReference/MethodRefSingleRefEvalBridge.java
+70
-0
test/tools/javac/lambda/methodReference/MethodRefToInner.java
.../tools/javac/lambda/methodReference/MethodRefToInner.java
+52
-0
test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java
.../methodReference/MethodReferenceComplexNullCheckTest.java
+54
-0
test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection1.java
...ethodReferenceExecution/MethodReferenceIntersection1.java
+88
-0
test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection2.java
...ethodReferenceExecution/MethodReferenceIntersection2.java
+68
-0
test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection3.java
...ethodReferenceExecution/MethodReferenceIntersection3.java
+50
-0
未找到文件。
.hgtags
浏览文件 @
aa1f2dfd
...
@@ -362,3 +362,4 @@ e7560bceb36a933f5eb6ce8c33dce030ba0288f2 jdk8u40-b12
...
@@ -362,3 +362,4 @@ e7560bceb36a933f5eb6ce8c33dce030ba0288f2 jdk8u40-b12
f18c5b47f27b387d94487890684abe5a554b0d9b jdk8u40-b14
f18c5b47f27b387d94487890684abe5a554b0d9b jdk8u40-b14
682a6c1aefd766eaf774ffeb1207a5189edf94d6 jdk8u40-b15
682a6c1aefd766eaf774ffeb1207a5189edf94d6 jdk8u40-b15
74c51ff270c51d17732250411fe9cd5392bc925e jdk8u40-b16
74c51ff270c51d17732250411fe9cd5392bc925e jdk8u40-b16
a12a9932f649dd3df174d3e340527433d3695c49 jdk8u40-b17
src/share/classes/com/sun/tools/javac/comp/Attr.java
浏览文件 @
aa1f2dfd
...
@@ -3226,8 +3226,9 @@ public class Attr extends JCTree.Visitor {
...
@@ -3226,8 +3226,9 @@ public class Attr extends JCTree.Visitor {
elt
=
((
ArrayType
)
elt
.
unannotatedType
()).
elemtype
;
elt
=
((
ArrayType
)
elt
.
unannotatedType
()).
elemtype
;
if
(
elt
.
hasTag
(
TYPEVAR
))
{
if
(
elt
.
hasTag
(
TYPEVAR
))
{
log
.
error
(
tree
.
pos
(),
"type.var.cant.be.deref"
);
log
.
error
(
tree
.
pos
(),
"type.var.cant.be.deref"
);
result
=
types
.
createErrorType
(
tree
.
type
);
result
=
tree
.
type
=
types
.
createErrorType
(
tree
.
name
,
site
.
tsym
,
site
);
return
;
tree
.
sym
=
tree
.
type
.
tsym
;
return
;
}
}
}
}
...
@@ -3243,6 +3244,10 @@ public class Attr extends JCTree.Visitor {
...
@@ -3243,6 +3244,10 @@ public class Attr extends JCTree.Visitor {
// Determine the symbol represented by the selection.
// Determine the symbol represented by the selection.
env
.
info
.
pendingResolutionPhase
=
null
;
env
.
info
.
pendingResolutionPhase
=
null
;
Symbol
sym
=
selectSym
(
tree
,
sitesym
,
site
,
env
,
resultInfo
);
Symbol
sym
=
selectSym
(
tree
,
sitesym
,
site
,
env
,
resultInfo
);
if
(
sym
.
kind
==
VAR
&&
sym
.
name
!=
names
.
_super
&&
env
.
info
.
defaultSuperCallSite
!=
null
)
{
log
.
error
(
tree
.
selected
.
pos
(),
"not.encl.class"
,
site
.
tsym
);
sym
=
syms
.
errSymbol
;
}
if
(
sym
.
exists
()
&&
!
isType
(
sym
)
&&
(
pkind
()
&
(
PCK
|
TYP
))
!=
0
)
{
if
(
sym
.
exists
()
&&
!
isType
(
sym
)
&&
(
pkind
()
&
(
PCK
|
TYP
))
!=
0
)
{
site
=
capture
(
site
);
site
=
capture
(
site
);
sym
=
selectSym
(
tree
,
sitesym
,
site
,
env
,
resultInfo
);
sym
=
selectSym
(
tree
,
sitesym
,
site
,
env
,
resultInfo
);
...
@@ -4499,14 +4504,15 @@ public class Attr extends JCTree.Visitor {
...
@@ -4499,14 +4504,15 @@ public class Attr extends JCTree.Visitor {
super
.
visitTypeTest
(
tree
);
super
.
visitTypeTest
(
tree
);
}
}
public
void
visitNewClass
(
JCNewClass
tree
)
{
public
void
visitNewClass
(
JCNewClass
tree
)
{
if
(
tree
.
clazz
.
hasTag
(
ANNOTATED_TYPE
))
{
if
(
tree
.
clazz
!=
null
&&
tree
.
clazz
.
type
!=
null
)
{
checkForDeclarationAnnotations
(((
JCAnnotatedType
)
tree
.
clazz
).
annotations
,
if
(
tree
.
clazz
.
hasTag
(
ANNOTATED_TYPE
))
{
tree
.
clazz
.
type
.
tsym
);
checkForDeclarationAnnotations
(((
JCAnnotatedType
)
tree
.
clazz
).
annotations
,
}
tree
.
clazz
.
type
.
tsym
);
if
(
tree
.
def
!=
null
)
{
}
checkForDeclarationAnnotations
(
tree
.
def
.
mods
.
annotations
,
tree
.
clazz
.
type
.
tsym
);
if
(
tree
.
def
!=
null
)
{
}
checkForDeclarationAnnotations
(
tree
.
def
.
mods
.
annotations
,
tree
.
clazz
.
type
.
tsym
);
if
(
tree
.
clazz
.
type
!=
null
)
{
}
validateAnnotatedType
(
tree
.
clazz
,
tree
.
clazz
.
type
);
validateAnnotatedType
(
tree
.
clazz
,
tree
.
clazz
.
type
);
}
}
super
.
visitNewClass
(
tree
);
super
.
visitNewClass
(
tree
);
...
...
src/share/classes/com/sun/tools/javac/comp/Flow.java
浏览文件 @
aa1f2dfd
...
@@ -242,9 +242,15 @@ public class Flow {
...
@@ -242,9 +242,15 @@ public class Flow {
Log
.
DiagnosticHandler
diagHandler
=
new
Log
.
DiscardDiagnosticHandler
(
log
);
Log
.
DiagnosticHandler
diagHandler
=
new
Log
.
DiscardDiagnosticHandler
(
log
);
try
{
try
{
new
AssignAnalyzer
()
{
new
AssignAnalyzer
()
{
Scope
enclosedSymbols
=
new
Scope
(
env
.
enclClass
.
sym
);
@Override
public
void
visitVarDef
(
JCVariableDecl
tree
)
{
enclosedSymbols
.
enter
(
tree
.
sym
);
super
.
visitVarDef
(
tree
);
}
@Override
@Override
protected
boolean
trackable
(
VarSymbol
sym
)
{
protected
boolean
trackable
(
VarSymbol
sym
)
{
return
!
env
.
info
.
scope
.
includes
(
sym
)
&&
return
enclosedSymbols
.
includes
(
sym
)
&&
sym
.
owner
.
kind
==
MTH
;
sym
.
owner
.
kind
==
MTH
;
}
}
}.
analyzeTree
(
env
,
that
);
}.
analyzeTree
(
env
,
that
);
...
...
src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
浏览文件 @
aa1f2dfd
此差异已折叠。
点击以展开。
src/share/classes/com/sun/tools/javac/comp/Lower.java
浏览文件 @
aa1f2dfd
...
@@ -2716,9 +2716,10 @@ public class Lower extends TreeTranslator {
...
@@ -2716,9 +2716,10 @@ public class Lower extends TreeTranslator {
syms
.
intType
,
tree
.
sym
);
syms
.
intType
,
tree
.
sym
);
ordParam
.
mods
.
flags
|=
SYNTHETIC
;
ordParam
.
sym
.
flags_field
|=
SYNTHETIC
;
ordParam
.
mods
.
flags
|=
SYNTHETIC
;
ordParam
.
sym
.
flags_field
|=
SYNTHETIC
;
MethodSymbol
m
=
tree
.
sym
;
tree
.
params
=
tree
.
params
.
prepend
(
ordParam
).
prepend
(
nameParam
);
tree
.
params
=
tree
.
params
.
prepend
(
ordParam
).
prepend
(
nameParam
);
incrementParamTypeAnnoIndexes
(
m
,
2
);
MethodSymbol
m
=
tree
.
sym
;
m
.
extraParams
=
m
.
extraParams
.
prepend
(
ordParam
.
sym
);
m
.
extraParams
=
m
.
extraParams
.
prepend
(
ordParam
.
sym
);
m
.
extraParams
=
m
.
extraParams
.
prepend
(
nameParam
.
sym
);
m
.
extraParams
=
m
.
extraParams
.
prepend
(
nameParam
.
sym
);
Type
olderasure
=
m
.
erasure
(
types
);
Type
olderasure
=
m
.
erasure
(
types
);
...
@@ -2741,6 +2742,17 @@ public class Lower extends TreeTranslator {
...
@@ -2741,6 +2742,17 @@ public class Lower extends TreeTranslator {
}
}
}
}
//where
//where
private
void
incrementParamTypeAnnoIndexes
(
MethodSymbol
m
,
int
amount
)
{
for
(
final
Attribute
.
TypeCompound
anno
:
m
.
getRawTypeAttributes
())
{
// Increment the parameter_index of any existing formal
// parameter annotations.
if
(
anno
.
position
.
type
==
TargetType
.
METHOD_FORMAL_PARAMETER
)
{
anno
.
position
.
parameter_index
+=
amount
;
}
}
}
private
void
visitMethodDefInternal
(
JCMethodDecl
tree
)
{
private
void
visitMethodDefInternal
(
JCMethodDecl
tree
)
{
if
(
tree
.
name
==
names
.
init
&&
if
(
tree
.
name
==
names
.
init
&&
(
currentClass
.
isInner
()
||
currentClass
.
isLocal
()))
{
(
currentClass
.
isInner
()
||
currentClass
.
isLocal
()))
{
...
@@ -2771,8 +2783,10 @@ public class Lower extends TreeTranslator {
...
@@ -2771,8 +2783,10 @@ public class Lower extends TreeTranslator {
// Add this$n (if needed) in front of and free variables behind
// Add this$n (if needed) in front of and free variables behind
// constructor parameter list.
// constructor parameter list.
tree
.
params
=
tree
.
params
.
appendList
(
fvdefs
);
tree
.
params
=
tree
.
params
.
appendList
(
fvdefs
);
if
(
currentClass
.
hasOuterInstance
())
if
(
currentClass
.
hasOuterInstance
())
{
tree
.
params
=
tree
.
params
.
prepend
(
otdef
);
tree
.
params
=
tree
.
params
.
prepend
(
otdef
);
incrementParamTypeAnnoIndexes
(
m
,
1
);
}
// If this is an initial constructor, i.e., it does not start with
// If this is an initial constructor, i.e., it does not start with
// this(...), insert initializers for this$n and proxies
// this(...), insert initializers for this$n and proxies
...
...
src/share/classes/com/sun/tools/javac/comp/Resolve.java
浏览文件 @
aa1f2dfd
...
@@ -3220,7 +3220,7 @@ public class Resolve {
...
@@ -3220,7 +3220,7 @@ public class Resolve {
super
(
referenceTree
,
name
,
site
,
argtypes
.
tail
,
typeargtypes
,
maxPhase
);
super
(
referenceTree
,
name
,
site
,
argtypes
.
tail
,
typeargtypes
,
maxPhase
);
if
(
site
.
isRaw
()
&&
!
argtypes
.
head
.
hasTag
(
NONE
))
{
if
(
site
.
isRaw
()
&&
!
argtypes
.
head
.
hasTag
(
NONE
))
{
Type
asSuperSite
=
types
.
asSuper
(
argtypes
.
head
,
site
.
tsym
);
Type
asSuperSite
=
types
.
asSuper
(
argtypes
.
head
,
site
.
tsym
);
this
.
site
=
asSuperSite
;
this
.
site
=
types
.
capture
(
asSuperSite
)
;
}
}
}
}
...
...
src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
浏览文件 @
aa1f2dfd
...
@@ -670,6 +670,27 @@ public class ClassWriter extends ClassFile {
...
@@ -670,6 +670,27 @@ public class ClassWriter extends ClassFile {
}
}
private
void
writeParamAnnotations
(
List
<
VarSymbol
>
params
,
RetentionPolicy
retention
)
{
for
(
VarSymbol
s
:
params
)
{
ListBuffer
<
Attribute
.
Compound
>
buf
=
new
ListBuffer
<>();
for
(
Attribute
.
Compound
a
:
s
.
getRawAttributes
())
if
(
types
.
getRetention
(
a
)
==
retention
)
buf
.
append
(
a
);
databuf
.
appendChar
(
buf
.
length
());
for
(
Attribute
.
Compound
a
:
buf
)
writeCompoundAttribute
(
a
);
}
}
private
void
writeParamAnnotations
(
MethodSymbol
m
,
RetentionPolicy
retention
)
{
databuf
.
appendByte
(
m
.
params
.
length
()
+
m
.
extraParams
.
length
());
writeParamAnnotations
(
m
.
extraParams
,
retention
);
writeParamAnnotations
(
m
.
params
,
retention
);
}
/** Write method parameter annotations;
/** Write method parameter annotations;
* return number of attributes written.
* return number of attributes written.
*/
*/
...
@@ -692,31 +713,13 @@ public class ClassWriter extends ClassFile {
...
@@ -692,31 +713,13 @@ public class ClassWriter extends ClassFile {
int
attrCount
=
0
;
int
attrCount
=
0
;
if
(
hasVisible
)
{
if
(
hasVisible
)
{
int
attrIndex
=
writeAttr
(
names
.
RuntimeVisibleParameterAnnotations
);
int
attrIndex
=
writeAttr
(
names
.
RuntimeVisibleParameterAnnotations
);
databuf
.
appendByte
(
m
.
params
.
length
());
writeParamAnnotations
(
m
,
RetentionPolicy
.
RUNTIME
);
for
(
VarSymbol
s
:
m
.
params
)
{
ListBuffer
<
Attribute
.
Compound
>
buf
=
new
ListBuffer
<
Attribute
.
Compound
>();
for
(
Attribute
.
Compound
a
:
s
.
getRawAttributes
())
if
(
types
.
getRetention
(
a
)
==
RetentionPolicy
.
RUNTIME
)
buf
.
append
(
a
);
databuf
.
appendChar
(
buf
.
length
());
for
(
Attribute
.
Compound
a
:
buf
)
writeCompoundAttribute
(
a
);
}
endAttr
(
attrIndex
);
endAttr
(
attrIndex
);
attrCount
++;
attrCount
++;
}
}
if
(
hasInvisible
)
{
if
(
hasInvisible
)
{
int
attrIndex
=
writeAttr
(
names
.
RuntimeInvisibleParameterAnnotations
);
int
attrIndex
=
writeAttr
(
names
.
RuntimeInvisibleParameterAnnotations
);
databuf
.
appendByte
(
m
.
params
.
length
());
writeParamAnnotations
(
m
,
RetentionPolicy
.
CLASS
);
for
(
VarSymbol
s
:
m
.
params
)
{
ListBuffer
<
Attribute
.
Compound
>
buf
=
new
ListBuffer
<
Attribute
.
Compound
>();
for
(
Attribute
.
Compound
a
:
s
.
getRawAttributes
())
if
(
types
.
getRetention
(
a
)
==
RetentionPolicy
.
CLASS
)
buf
.
append
(
a
);
databuf
.
appendChar
(
buf
.
length
());
for
(
Attribute
.
Compound
a
:
buf
)
writeCompoundAttribute
(
a
);
}
endAttr
(
attrIndex
);
endAttr
(
attrIndex
);
attrCount
++;
attrCount
++;
}
}
...
...
test/lib/annotations/annotations/classfile/ClassfileInspector.java
0 → 100644
浏览文件 @
aa1f2dfd
此差异已折叠。
点击以展开。
test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* @test /nodynamiccopyright/
* @bug 8062359
* @summary NullPointerException in Attr when type-annotating an anonymous
* inner class in an unresolvable class
* @compile/fail/ref=UnresolvableClassNPEInAttrTest.out -XDrawDiagnostics UnresolvableClassNPEInAttrTest.java
*/
public
class
UnresolvableClassNPEInAttrTest
{
public
static
void
main
(
String
[]
args
)
{
new
Undefined
()
{
void
test
()
{
new
Object
()
{};
}
};
}
}
test/tools/javac/8062359/UnresolvableClassNPEInAttrTest.out
0 → 100644
浏览文件 @
aa1f2dfd
UnresolvableClassNPEInAttrTest.java:11:13: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, UnresolvableClassNPEInAttrTest, null)
1 error
test/tools/javac/T8019486/WrongLNTForLambdaTest.java
浏览文件 @
aa1f2dfd
...
@@ -138,7 +138,7 @@ public class WrongLNTForLambdaTest {
...
@@ -138,7 +138,7 @@ public class WrongLNTForLambdaTest {
checkClassFile
(
new
File
(
Paths
.
get
(
System
.
getProperty
(
"user.dir"
),
checkClassFile
(
new
File
(
Paths
.
get
(
System
.
getProperty
(
"user.dir"
),
"Foo.class"
).
toUri
()),
"$deserializeLambda$"
,
deserializeExpectedLNT
);
"Foo.class"
).
toUri
()),
"$deserializeLambda$"
,
deserializeExpectedLNT
);
checkClassFile
(
new
File
(
Paths
.
get
(
System
.
getProperty
(
"user.dir"
),
checkClassFile
(
new
File
(
Paths
.
get
(
System
.
getProperty
(
"user.dir"
),
"Foo.class"
).
toUri
()),
"lambda$
MR$variablesInLambdas$notify$8bc4f5bd$1
"
,
lambdaBridgeExpectedLNT
);
"Foo.class"
).
toUri
()),
"lambda$
variablesInLambdas$3
"
,
lambdaBridgeExpectedLNT
);
checkClassFile
(
new
File
(
Paths
.
get
(
System
.
getProperty
(
"user.dir"
),
checkClassFile
(
new
File
(
Paths
.
get
(
System
.
getProperty
(
"user.dir"
),
"Foo.class"
).
toUri
()),
"assignLambda"
,
assignmentExpectedLNT
);
"Foo.class"
).
toUri
()),
"assignLambda"
,
assignmentExpectedLNT
);
checkClassFile
(
new
File
(
Paths
.
get
(
System
.
getProperty
(
"user.dir"
),
checkClassFile
(
new
File
(
Paths
.
get
(
System
.
getProperty
(
"user.dir"
),
...
...
test/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* @test /nodynamiccopyright/
* @bug 8059921
* @summary Missing compile error in Java 8 mode for Interface.super.field access
* @compile/fail/ref=ForbidAccessToFieldUsingSuperTest.out -XDrawDiagnostics ForbidAccessToFieldUsingSuperTest.java
*/
public
class
ForbidAccessToFieldUsingSuperTest
{
class
C
{
int
m
()
{
return
0
;
}
}
interface
T
{
int
f
=
0
;
C
c
=
null
;
default
int
mm
()
{
return
0
;
}
}
interface
T1
extends
T
{}
class
X
implements
T1
{
int
i
=
T1
.
super
.
f
;
//fail
int
j
=
T1
.
super
.
c
.
m
();
//fail
void
foo
(
Runnable
r
)
{
foo
(
T1
.
super
::
mm
);
//should'n fail
}
}
}
test/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.out
0 → 100644
浏览文件 @
aa1f2dfd
ForbidAccessToFieldUsingSuperTest.java:24:19: compiler.err.not.encl.class: ForbidAccessToFieldUsingSuperTest.T1
ForbidAccessToFieldUsingSuperTest.java:25:19: compiler.err.not.encl.class: ForbidAccessToFieldUsingSuperTest.T1
2 errors
test/tools/javac/annotations/SyntheticParameters.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 SyntheticParameters
* @bug 8065132
* @summary Test generation of annotations on inner class parameters.
* @library /lib/annotations/
* @run main SyntheticParameters
*/
import
annotations.classfile.ClassfileInspector
;
import
java.io.*
;
import
java.lang.annotation.*
;
import
com.sun.tools.classfile.*
;
public
class
SyntheticParameters
extends
ClassfileInspector
{
private
static
final
String
Inner_class
=
"SyntheticParameters$Inner.class"
;
private
static
final
String
Foo_class
=
"SyntheticParameters$Foo.class"
;
private
static
final
Expected
Inner_expected
=
new
Expected
(
"SyntheticParameters$Inner"
,
null
,
null
,
new
ExpectedParameterAnnotation
[]
{
(
ExpectedParameterAnnotation
)
// Assert there is no annotation on the
// this$0 parameter.
new
ExpectedParameterAnnotation
(
"<init>"
,
0
,
"A"
,
true
,
0
),
(
ExpectedParameterAnnotation
)
// Assert there is an annotation on the
// first parameter.
new
ExpectedParameterAnnotation
(
"<init>"
,
1
,
"A"
,
true
,
1
),
(
ExpectedParameterAnnotation
)
new
ExpectedParameterAnnotation
(
"foo"
,
0
,
"A"
,
true
,
1
),
(
ExpectedParameterAnnotation
)
new
ExpectedParameterAnnotation
(
"foo"
,
1
,
"A"
,
true
,
0
),
(
ExpectedParameterAnnotation
)
// Assert there is no annotation on the
// this$0 parameter.
new
ExpectedParameterAnnotation
(
"<init>"
,
0
,
"B"
,
false
,
0
),
(
ExpectedParameterAnnotation
)
// Assert there is an annotation on the
// first parameter.
new
ExpectedParameterAnnotation
(
"<init>"
,
1
,
"B"
,
false
,
1
),
(
ExpectedParameterAnnotation
)
new
ExpectedParameterAnnotation
(
"foo"
,
0
,
"B"
,
false
,
1
),
(
ExpectedParameterAnnotation
)
new
ExpectedParameterAnnotation
(
"foo"
,
1
,
"B"
,
false
,
0
)
},
null
);
private
static
final
Expected
Foo_expected
=
new
Expected
(
"SyntheticParameters$Foo"
,
null
,
null
,
new
ExpectedParameterAnnotation
[]
{
(
ExpectedParameterAnnotation
)
// Assert there is no annotation on the
// $enum$name parameter.
new
ExpectedParameterAnnotation
(
"<init>"
,
0
,
"A"
,
true
,
0
),
(
ExpectedParameterAnnotation
)
// Assert there is no annotation on the
// $enum$ordinal parameter.
new
ExpectedParameterAnnotation
(
"<init>"
,
1
,
"A"
,
true
,
0
),
(
ExpectedParameterAnnotation
)
// Assert there is an annotation on the
// first parameter.
new
ExpectedParameterAnnotation
(
"<init>"
,
2
,
"A"
,
true
,
1
),
(
ExpectedParameterAnnotation
)
// Assert there is no annotation on the
// $enum$name parameter.
new
ExpectedParameterAnnotation
(
"<init>"
,
0
,
"B"
,
false
,
0
),
(
ExpectedParameterAnnotation
)
// Assert there is no annotation on the
// $enum$ordinal parameter.
new
ExpectedParameterAnnotation
(
"<init>"
,
1
,
"B"
,
false
,
0
),
(
ExpectedParameterAnnotation
)
// Assert there is an annotation on the
// first parameter.
new
ExpectedParameterAnnotation
(
"<init>"
,
2
,
"B"
,
false
,
1
)
},
null
);
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
SyntheticParameters
().
run
(
new
ClassFile
[]
{
getClassFile
(
Inner_class
,
Inner
.
class
),
getClassFile
(
Foo_class
,
Foo
.
class
)
},
new
Expected
[]
{
Inner_expected
,
Foo_expected
});
}
public
class
Inner
{
public
Inner
(
@A
@B
int
a
)
{}
public
void
foo
(
@A
@B
int
a
,
int
b
)
{}
}
public
static
enum
Foo
{
ONE
(
null
);
Foo
(
@A
@B
Object
a
)
{}
}
}
@Retention
(
RetentionPolicy
.
RUNTIME
)
@interface
A
{}
@Retention
(
RetentionPolicy
.
CLASS
)
@interface
B
{}
test/tools/javac/annotations/typeAnnotations/classfile/SyntheticParameters.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 SyntheticParameters
* @summary Test generation of annotations on inner class parameters.
* @library /lib/annotations/
* @run main SyntheticParameters
*/
import
annotations.classfile.ClassfileInspector
;
import
java.io.*
;
import
java.lang.annotation.*
;
import
com.sun.tools.classfile.*
;
public
class
SyntheticParameters
extends
ClassfileInspector
{
private
static
final
String
Inner_class
=
"SyntheticParameters$Inner.class"
;
private
static
final
String
Foo_class
=
"SyntheticParameters$Foo.class"
;
private
static
final
Expected
Inner_expected
=
new
Expected
(
"SyntheticParameters$Inner"
,
null
,
new
ExpectedMethodTypeAnnotation
[]
{
(
ExpectedMethodTypeAnnotation
)
// Assert there is no annotation on the
// this$0 parameter.
new
ExpectedMethodTypeAnnotation
.
Builder
(
"<init>"
,
"A"
,
TypeAnnotation
.
TargetType
.
METHOD_FORMAL_PARAMETER
,
false
,
0
).
setParameterIndex
(
0
).
build
(),
(
ExpectedMethodTypeAnnotation
)
// Assert there is an annotation on the
// first parameter.
new
ExpectedMethodTypeAnnotation
.
Builder
(
"<init>"
,
"A"
,
TypeAnnotation
.
TargetType
.
METHOD_FORMAL_PARAMETER
,
false
,
1
).
setParameterIndex
(
1
).
build
(),
(
ExpectedMethodTypeAnnotation
)
new
ExpectedMethodTypeAnnotation
.
Builder
(
"foo"
,
"A"
,
TypeAnnotation
.
TargetType
.
METHOD_FORMAL_PARAMETER
,
false
,
1
).
setParameterIndex
(
0
).
build
(),
(
ExpectedMethodTypeAnnotation
)
new
ExpectedMethodTypeAnnotation
.
Builder
(
"foo"
,
"A"
,
TypeAnnotation
.
TargetType
.
METHOD_FORMAL_PARAMETER
,
false
,
0
).
setParameterIndex
(
1
).
build
()
},
null
);
private
static
final
Expected
Foo_expected
=
new
Expected
(
"SyntheticParameters$Foo"
,
null
,
new
ExpectedMethodTypeAnnotation
[]
{
(
ExpectedMethodTypeAnnotation
)
// Assert there is no annotation on the
// $enum$name parameter.
new
ExpectedMethodTypeAnnotation
.
Builder
(
"<init>"
,
"A"
,
TypeAnnotation
.
TargetType
.
METHOD_FORMAL_PARAMETER
,
false
,
0
).
setParameterIndex
(
0
).
build
(),
(
ExpectedMethodTypeAnnotation
)
// Assert there is no annotation on the
// $enum$ordinal parameter.
new
ExpectedMethodTypeAnnotation
.
Builder
(
"<init>"
,
"A"
,
TypeAnnotation
.
TargetType
.
METHOD_FORMAL_PARAMETER
,
false
,
0
).
setParameterIndex
(
1
).
build
(),
(
ExpectedMethodTypeAnnotation
)
// Assert there is an annotation on the
// first parameter.
new
ExpectedMethodTypeAnnotation
.
Builder
(
"<init>"
,
"A"
,
TypeAnnotation
.
TargetType
.
METHOD_FORMAL_PARAMETER
,
false
,
1
).
setParameterIndex
(
2
).
build
()
},
null
);
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
SyntheticParameters
().
run
(
new
ClassFile
[]
{
getClassFile
(
Inner_class
,
Inner
.
class
),
getClassFile
(
Foo_class
,
Foo
.
class
)
},
new
Expected
[]
{
Inner_expected
,
Foo_expected
});
}
public
class
Inner
{
public
Inner
(
@A
int
a
)
{}
public
void
foo
(
@A
int
a
,
int
b
)
{}
}
public
static
enum
Foo
{
ONE
(
null
);
Foo
(
@A
Object
a
)
{}
}
}
@Target
({
ElementType
.
TYPE_USE
})
@interface
A
{}
test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
浏览文件 @
aa1f2dfd
...
@@ -46,7 +46,7 @@ public class Constructors {
...
@@ -46,7 +46,7 @@ public class Constructors {
@TADescriptions
({
@TADescriptions
({
@TADescription
(
annotation
=
"TA"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
}),
@TADescription
(
annotation
=
"TA"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
}),
@TADescription
(
annotation
=
"TB"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
}),
@TADescription
(
annotation
=
"TB"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
}),
@TADescription
(
annotation
=
"TC"
,
type
=
METHOD_FORMAL_PARAMETER
,
paramIndex
=
0
)
@TADescription
(
annotation
=
"TC"
,
type
=
METHOD_FORMAL_PARAMETER
,
paramIndex
=
1
)
})
})
@TestClass
(
"Test$Inner"
)
@TestClass
(
"Test$Inner"
)
public
String
innerClass
()
{
public
String
innerClass
()
{
...
@@ -61,7 +61,7 @@ public class Constructors {
...
@@ -61,7 +61,7 @@ public class Constructors {
@TADescription
(
annotation
=
"TB"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
}),
@TADescription
(
annotation
=
"TB"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
}),
@TADescription
(
annotation
=
"TC"
,
type
=
METHOD_RECEIVER
),
@TADescription
(
annotation
=
"TC"
,
type
=
METHOD_RECEIVER
),
@TADescription
(
annotation
=
"TD"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
}),
@TADescription
(
annotation
=
"TD"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
}),
@TADescription
(
annotation
=
"TE"
,
type
=
METHOD_FORMAL_PARAMETER
,
paramIndex
=
0
)
@TADescription
(
annotation
=
"TE"
,
type
=
METHOD_FORMAL_PARAMETER
,
paramIndex
=
1
)
})
})
@TestClass
(
"Test$Inner"
)
@TestClass
(
"Test$Inner"
)
public
String
innerClass2
()
{
public
String
innerClass2
()
{
...
@@ -77,7 +77,7 @@ public class Constructors {
...
@@ -77,7 +77,7 @@ public class Constructors {
@TADescription
(
annotation
=
"TC"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
,
1
,
0
}),
@TADescription
(
annotation
=
"TC"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
,
1
,
0
}),
@TADescription
(
annotation
=
"TD"
,
type
=
METHOD_RECEIVER
,
genericLocation
=
{
1
,
0
}),
@TADescription
(
annotation
=
"TD"
,
type
=
METHOD_RECEIVER
,
genericLocation
=
{
1
,
0
}),
@TADescription
(
annotation
=
"TE"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
,
1
,
0
}),
@TADescription
(
annotation
=
"TE"
,
type
=
METHOD_RETURN
,
genericLocation
=
{
1
,
0
,
1
,
0
}),
@TADescription
(
annotation
=
"TF"
,
type
=
METHOD_FORMAL_PARAMETER
,
paramIndex
=
0
)
@TADescription
(
annotation
=
"TF"
,
type
=
METHOD_FORMAL_PARAMETER
,
paramIndex
=
1
)
})
})
@TestClass
(
"Outer$Middle$Inner"
)
@TestClass
(
"Outer$Middle$Inner"
)
public
String
innerClass3
()
{
public
String
innerClass3
()
{
...
...
test/tools/javac/flow/T8062747.java
0 → 100644
浏览文件 @
aa1f2dfd
/**
* @test
* @bug 8062747
* @summary Avoiding an error for lambdas with thrown types inference inside an anonymous class.
* @compile T8062747.java
*/
public
class
T8062747
{
public
interface
Throwing
<
Y
extends
Exception
>
{
void
canThrow
()
throws
Y
;
}
public
static
<
Y
extends
Exception
>
void
wrap
(
Throwing
<
Y
>
action
)
{
}
public
static
void
invoke
(
String
a
)
{
Runnable
r
=
new
Runnable
()
{
@Override
public
void
run
()
{
wrap
(()
->
System
.
out
.
println
(
a
));
}
};
}
}
test/tools/javac/lambda/T8057794.java
0 → 100644
浏览文件 @
aa1f2dfd
/**
* @test /nodynamiccopyright/
* @bug 8057794
* @summary The tree for TypeVar.class does not have a type set, which leads to an NPE when
* checking if deferred attribution is needed
* @compile/fail/ref=T8057794.out -XDrawDiagnostics T8057794.java
*/
class
T8057794
<
T
>
{
void
t
()
{
System
.
out
.
println
(
T
.
class
.
getSimpleName
());
}
}
test/tools/javac/lambda/T8057794.out
0 → 100644
浏览文件 @
aa1f2dfd
T8057794.java:10:29: compiler.err.type.var.cant.be.deref
1 error
test/tools/javac/lambda/methodReference/MethodRef8.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8063052
* @summary Inference chokes on wildcard derived from method reference
* @compile MethodRef8.java
*/
public
class
MethodRef8
{
void
test
(
Box
<?
extends
Box
<?
extends
Number
>>
b
)
{
Number
n1
=
b
.
map
(
Box:
:
get
).
get
();
Number
n2
=
b
.<
Number
>
map
(
Box:
:
get
).
get
();
}
interface
Func
<
S
,
T
>
{
T
apply
(
S
arg
);
}
interface
Box
<
T
>
{
T
get
();
<
R
>
Box
<
R
>
map
(
Func
<
T
,
R
>
f
);
}
}
test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8044748
* @summary JVM cannot access constructor though ::new reference although can call it directly
*/
public
class
MethodRefNewInnerBootstrap
{
interface
Constructor
{
public
MyTest
execute
(
int
i
);
}
public
class
MyTest
{
public
MyTest
(
int
i
)
{
System
.
out
.
println
(
"Constructor executed "
+
i
);
}
}
public
Constructor
getConstructor
()
{
return
MyTest:
:
new
;
}
public
static
void
main
(
String
argv
[])
{
new
MethodRefNewInnerBootstrap
().
call
();
}
public
void
call
()
{
MyTest
mt
=
new
MyTest
(
0
);
Constructor
c1
=
MyTest:
:
new
;
c1
.
execute
(
1
);
Constructor
c2
=
getConstructor
();
c2
.
execute
(
2
);
Constructor
c3
=
new
Constructor
()
{
public
MyTest
execute
(
int
i
)
{
return
new
MyTest
(
3
);
}
};
c3
.
execute
(
3
);
Constructor
c4
=
new
Constructor
()
{
public
MyTest
execute
(
int
i
)
{
Constructor
c
=
MyTest:
:
new
;
return
c
.
execute
(
i
);
}
};
c4
.
execute
(
4
);
}
}
test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8037404
* @summary javac NPE or VerifyError for code with constructor reference of inner class
*/
import
java.util.function.Supplier
;
import
java.util.stream.Stream
;
public
class
MethodRefNewInnerInLambdaNPE1
{
public
static
void
main
(
String
[]
args
)
{
if
(
new
MethodRefNewInnerInLambdaNPE1
().
getList
().
get
().
getClass
()
!=
TT
.
class
)
throw
new
AssertionError
(
"sanity failed"
);
}
Supplier
<
TT
>
getList
()
{
return
()
->
Stream
.
of
(
1
).
map
(
TT:
:
new
).
findFirst
().
get
();
}
class
TT
{
public
TT
(
int
i
)
{
}
}
}
test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8044737
* @summary Lambda: NPE while obtaining method reference through lambda expression
* @compile MethodRefNewInnerInLambdaNPE2.java
*/
public
class
MethodRefNewInnerInLambdaNPE2
{
interface
Constructor
{
MyTest
execute
();
}
class
MyTest
{
MyTest
()
{
System
.
out
.
println
(
"Constructor executed"
);
}
}
public
Constructor
getConstructor
()
{
return
getConstructor
(()
->
{
return
MyTest:
:
new
;
});
}
public
static
void
main
(
String
argv
[])
{
MethodRefNewInnerInLambdaNPE2
t
=
new
MethodRefNewInnerInLambdaNPE2
();
MyTest
mytest
=
t
.
getConstructor
().
execute
();
}
Constructor
getConstructor
(
Wrapper
arg
)
{
return
arg
.
unwrap
();
}
interface
Wrapper
{
Constructor
unwrap
();
}
}
test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8037404
* @summary javac NPE or VerifyError for code with constructor reference of inner class
*/
import
java.util.function.Function
;
import
java.util.stream.Stream
;
public
class
MethodRefNewInnerInLambdaVerify1
{
public
static
void
main
(
String
[]
args
)
{
if
(
new
MethodRefNewInnerInLambdaVerify1
().
map
().
apply
(
1
).
getClass
()
!=
TT
.
class
)
throw
new
AssertionError
(
"sanity failed"
);
}
Function
<
Integer
,
TT
>
map
()
{
return
(
i
)
->
Stream
.
of
(
i
).
map
(
TT:
:
new
).
findFirst
().
get
();
}
class
TT
{
public
TT
(
int
i
)
{
}
}
}
test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8038776
* @summary VerifyError when running successfully compiled java class
*/
import
java.util.function.Function
;
/**
* Derived from code by:
* @author Yawkat
*/
public
class
MethodRefNewInnerInLambdaVerify2
{
public
static
void
main
(
String
[]
args
)
{
new
MethodRefNewInnerInLambdaVerify2
().
runTest
();
}
private
void
runTest
()
{
Worker
worker
=
new
Worker
();
run
(()
->
worker
.
check
(
field
->
new
SomeClass
(
field
)));
run
(()
->
worker
.
check
(
SomeClass:
:
new
));
}
private
void
run
(
Runnable
runnable
)
{
runnable
.
run
();
}
private
class
SomeClass
{
final
Object
field
;
SomeClass
(
Object
field
)
{
this
.
field
=
field
;
}
}
private
static
class
Worker
{
void
check
(
Function
<
Object
,
SomeClass
>
i
)
{
if
(!
i
.
apply
(
"frank"
).
field
.
equals
(
"frank"
))
throw
new
AssertionError
(
"sanity failed"
);
}
}
}
test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8038776
* @summary VerifyError when running successfully compiled java class
*/
import
java.util.function.Function
;
/**
* Derived from code by:
* @author Yawkat
*/
public
class
MethodRefNewInnerInLambdaVerify2simple
{
public
static
void
main
(
String
[]
args
)
{
new
MethodRefNewInnerInLambdaVerify2simple
().
runTest
();
}
private
void
runTest
()
{
Runnable
r
=
(()
->
{
Sup
w
=
SomeClass:
:
new
;
}
);
}
private
class
SomeClass
{
SomeClass
()
{
}
}
}
interface
Sup
{
Object
get
();
}
test/tools/javac/lambda/methodReference/MethodRefQualifier1.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8048121
* @summary javac complex method references: revamp and simplify
*/
public
class
MethodRefQualifier1
{
interface
SAM
{
void
m
();
}
static
int
count
=
0
;
static
void
assertTrue
(
boolean
cond
,
String
msg
)
{
if
(!
cond
)
throw
new
AssertionError
(
msg
);
}
MethodRefQualifier1
check
()
{
count
++;
return
this
;
}
void
ido
(
Object
...
args
)
{
}
public
static
void
main
(
String
[]
args
)
{
new
MethodRefQualifier1
().
test
();
}
void
test
()
{
count
=
0
;
SAM
s
=
check
()::
ido
;
assertTrue
(
count
==
1
,
"creation: unexpected: "
+
count
);
count
=
0
;
s
.
m
();
assertTrue
(
count
==
0
,
"evaluation: unexpected: "
+
count
);
}
}
test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8048121
* @summary javac complex method references: revamp and simplify
*
* Make sure that the method reference receiver is evaluated exactly once
* even in this bridging case.
*/
public
class
MethodRefSingleRefEvalBridge
{
interface
SAM
{
int
m
();
}
class
ZZ
{
// private to force bridging
private
int
four
()
{
return
4
;
}
}
static
int
count
=
0
;
ZZ
azz
=
new
ZZ
();
static
void
assertEqual
(
int
expected
,
int
got
)
{
if
(
got
!=
expected
)
throw
new
AssertionError
(
"Expected "
+
expected
+
" got "
+
got
);
}
public
static
void
main
(
String
[]
args
)
{
new
MethodRefSingleRefEvalBridge
().
test
();
}
ZZ
check
()
{
count
++;
return
azz
;
}
void
test
()
{
count
=
0
;
SAM
s
=
check
()::
four
;
assertEqual
(
1
,
count
);
count
=
0
;
assertEqual
(
4
,
s
.
m
());
assertEqual
(
0
,
count
);
}
}
test/tools/javac/lambda/methodReference/MethodRefToInner.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8047341
* @summary lambda reference to inner class in base class causes LambdaConversionException
*/
import
java.util.List
;
import
java.util.ArrayList
;
class
MethodRefToInnerBase
{
class
TestString
{
String
str
;
TestString
(
String
strin
)
{
str
=
strin
;
}
}
}
public
class
MethodRefToInner
extends
MethodRefToInnerBase
{
public
static
void
main
(
String
[]
args
)
{
new
MethodRefToInner
().
run
();
}
MethodRefToInner
()
{
super
();
}
void
run
()
{
List
<
String
>
list
=
new
ArrayList
<>();
list
.
stream
().
forEach
(
TestString:
:
new
);
}
}
test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8048121
* @summary javac complex method references: revamp and simplify
*
* Make sure NPE check is done even in the convert to Lambda case
*/
public
class
MethodReferenceComplexNullCheckTest
{
public
static
void
main
(
String
[]
args
)
{
F
fr
=
null
;
boolean
npeFired
=
false
;
try
{
IForm
frf
=
fr:
:
doit
;
}
catch
(
NullPointerException
npe
)
{
npeFired
=
true
;
}
finally
{
if
(!
npeFired
)
throw
new
AssertionError
(
"NPE should have been thrown"
);
}
}
interface
IForm
{
void
xyz
(
Object
...
args
);
}
class
F
{
private
void
doit
(
Object
...
args
)
{
}
}
}
test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection1.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8058112
* @summary Invalid BootstrapMethod for constructor/method reference
*/
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.List
;
import
static
java
.
util
.
stream
.
Collectors
.
toList
;
public
class
MethodReferenceIntersection1
{
public
static
void
main
(
String
[]
args
)
{
MethodReferenceIntersection1
main
=
new
MethodReferenceIntersection1
();
List
<
Info_MRI1
>
list
=
main
.
toInfoListError
(
Arrays
.
asList
(
new
Base_MRI1
()));
System
.
out
.
printf
(
"result %d\n"
,
list
.
size
());
}
public
<
H
extends
B_MRI1
&
A_MRI1
>
List
<
Info_MRI1
>
toInfoListError
(
List
<
H
>
list
)
{
Comparator
<
B_MRI1
>
byNameComparator
=
(
B_MRI1
b1
,
B_MRI1
b2
)
->
b1
.
getB
().
compareToIgnoreCase
(
b2
.
getB
());
return
list
.
stream
().
sorted
(
byNameComparator
).
map
(
Info_MRI1:
:
new
).
collect
(
toList
());
}
public
<
H
extends
B_MRI1
&
A_MRI1
>
List
<
Info_MRI1
>
toInfoListWorks
(
List
<
H
>
list
)
{
Comparator
<
B_MRI1
>
byNameComparator
=
(
B_MRI1
b1
,
B_MRI1
b2
)
->
b1
.
getB
().
compareToIgnoreCase
(
b2
.
getB
());
return
list
.
stream
().
sorted
(
byNameComparator
).
map
(
s
->
new
Info_MRI1
(
s
)).
collect
(
toList
());
}
}
interface
B_MRI1
{
public
String
getB
();
}
interface
A_MRI1
{
public
long
getA
();
}
class
Info_MRI1
{
private
final
long
a
;
private
final
String
b
;
<
H
extends
A_MRI1
&
B_MRI1
>
Info_MRI1
(
H
h
)
{
a
=
h
.
getA
();
b
=
h
.
getB
();
}
}
class
Base_MRI1
implements
A_MRI1
,
B_MRI1
{
@Override
public
long
getA
()
{
return
7L
;
}
@Override
public
String
getB
()
{
return
"hello"
;
}
}
test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection2.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8058112
* @summary Invalid BootstrapMethod for constructor/method reference
*/
import
java.util.function.Function
;
public
class
MethodReferenceIntersection2
{
interface
B
{
}
interface
A
{
}
static
class
C
implements
A
,
B
{
}
static
class
Info
{
<
H
extends
A
&
B
>
Info
(
H
h
)
{
}
static
<
H
extends
A
&
B
>
Info
info
(
H
h
)
{
return
new
Info
(
h
);
}
}
public
static
void
main
(
String
[]
args
)
{
test
();
}
// Note the switch in order compared to that on Info
static
<
H
extends
B
&
A
>
void
test
()
{
Function
<
H
,
Info
>
f1L
=
_h
->
new
Info
(
_h
);
Function
<
H
,
Info
>
f1
=
Info:
:
new
;
Function
<
H
,
Info
>
f2L
=
_h
->
Info
.
info
(
_h
);
Function
<
H
,
Info
>
f2
=
Info:
:
info
;
H
c
=
(
H
)
new
C
();
if
(
f1
.
apply
(
c
)
instanceof
Info
&&
f2
.
apply
(
c
)
instanceof
Info
)
{
System
.
out
.
println
(
"Passes."
);
}
else
{
throw
new
AssertionError
();
}
}
}
test/tools/javac/lambda/methodReferenceExecution/MethodReferenceIntersection3.java
0 → 100644
浏览文件 @
aa1f2dfd
/*
* 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 8058112
* @summary Invalid BootstrapMethod for constructor/method reference
*/
/**
* @author Remi Forax
*/
public
class
MethodReferenceIntersection3
{
interface
A
{}
interface
Foo
{
<
T
extends
Object
&
A
>
void
foo
(
T
t
);
}
static
<
T
extends
A
>
void
bar
(
T
t
)
{
}
public
static
void
main
(
String
[]
args
)
{
Foo
foo
=
MethodReferenceIntersection3:
:
bar
;
foo
.
foo
(
new
A
(){});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录