Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
00b7c1d1
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看板
提交
00b7c1d1
编写于
4月 11, 2014
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
2cf8ae0a
dfd35bf0
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
407 addition
and
31 deletion
+407
-31
src/share/classes/com/sun/tools/javac/code/Source.java
src/share/classes/com/sun/tools/javac/code/Source.java
+3
-0
src/share/classes/com/sun/tools/javac/comp/Attr.java
src/share/classes/com/sun/tools/javac/comp/Attr.java
+0
-21
src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
...hare/classes/com/sun/tools/javac/comp/LambdaToMethod.java
+2
-2
src/share/classes/com/sun/tools/javac/comp/TransTypes.java
src/share/classes/com/sun/tools/javac/comp/TransTypes.java
+3
-1
src/share/classes/com/sun/tools/javac/parser/JavacParser.java
...share/classes/com/sun/tools/javac/parser/JavacParser.java
+13
-1
src/share/classes/com/sun/tools/javac/resources/compiler.properties
...classes/com/sun/tools/javac/resources/compiler.properties
+5
-0
src/share/classes/com/sun/tools/javac/sym/Profiles.java
src/share/classes/com/sun/tools/javac/sym/Profiles.java
+14
-1
test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.out
...otations/typeAnnotations/failures/CantAnnotateScoping.out
+2
-1
test/tools/javac/annotations/typeAnnotations/failures/CheckErrorsForSource7.java
...tions/typeAnnotations/failures/CheckErrorsForSource7.java
+195
-0
test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out
...otations/failures/common/arrays/DeclarationAnnotation.out
+1
-1
test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java
...faultMethods/static/hiding/InterfaceMethodHidingTest.java
+2
-1
test/tools/javac/diags/examples/AnnotationsAfterTypeParamsNotSupportedInSource.java
...mples/AnnotationsAfterTypeParamsNotSupportedInSource.java
+34
-0
test/tools/javac/lambda/FunctionalInterfaceConversionTest.java
...tools/javac/lambda/FunctionalInterfaceConversionTest.java
+2
-2
test/tools/javac/lambda/T8037935/LambdaWithBinOpConstRefToConstString.java
...lambda/T8037935/LambdaWithBinOpConstRefToConstString.java
+43
-0
test/tools/javac/lambda/T8038420/LambdaIncrement.java
test/tools/javac/lambda/T8038420/LambdaIncrement.java
+52
-0
test/tools/javac/varargs/MethodHandleCrash.java
test/tools/javac/varargs/MethodHandleCrash.java
+36
-0
未找到文件。
src/share/classes/com/sun/tools/javac/code/Source.java
浏览文件 @
00b7c1d1
...
...
@@ -215,6 +215,9 @@ public enum Source {
public
boolean
allowTypeAnnotations
()
{
return
compareTo
(
JDK1_8
)
>=
0
;
}
public
boolean
allowAnnotationsAfterTypeParams
()
{
return
compareTo
(
JDK1_8
)
>=
0
;
}
public
boolean
allowRepeatedAnnotations
()
{
return
compareTo
(
JDK1_8
)
>=
0
;
}
...
...
src/share/classes/com/sun/tools/javac/comp/Attr.java
浏览文件 @
00b7c1d1
...
...
@@ -3009,15 +3009,6 @@ public class Attr extends JCTree.Visitor {
Type
ctype
=
cfolder
.
fold1
(
opc
,
argtype
);
if
(
ctype
!=
null
)
{
owntype
=
cfolder
.
coerce
(
ctype
,
owntype
);
// Remove constant types from arguments to
// conserve space. The parser will fold concatenations
// of string literals; the code here also
// gets rid of intermediate results when some of the
// operands are constant identifiers.
if
(
tree
.
arg
.
type
.
tsym
==
syms
.
stringType
.
tsym
)
{
tree
.
arg
.
type
=
syms
.
stringType
;
}
}
}
}
...
...
@@ -3051,18 +3042,6 @@ public class Attr extends JCTree.Visitor {
Type
ctype
=
cfolder
.
fold2
(
opc
,
left
,
right
);
if
(
ctype
!=
null
)
{
owntype
=
cfolder
.
coerce
(
ctype
,
owntype
);
// Remove constant types from arguments to
// conserve space. The parser will fold concatenations
// of string literals; the code here also
// gets rid of intermediate results when some of the
// operands are constant identifiers.
if
(
tree
.
lhs
.
type
.
tsym
==
syms
.
stringType
.
tsym
)
{
tree
.
lhs
.
type
=
syms
.
stringType
;
}
if
(
tree
.
rhs
.
type
.
tsym
==
syms
.
stringType
.
tsym
)
{
tree
.
rhs
.
type
=
syms
.
stringType
;
}
}
}
...
...
src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
浏览文件 @
00b7c1d1
...
...
@@ -1895,11 +1895,11 @@ public class LambdaToMethod extends TreeTranslator {
};
break
;
case
LOCAL_VAR:
ret
=
new
VarSymbol
(
FINAL
,
name
,
types
.
erasure
(
sym
.
type
),
translatedSym
);
ret
=
new
VarSymbol
(
sym
.
flags
()
&
FINAL
,
name
,
types
.
erasure
(
sym
.
type
),
translatedSym
);
((
VarSymbol
)
ret
).
pos
=
((
VarSymbol
)
sym
).
pos
;
break
;
case
PARAM:
ret
=
new
VarSymbol
(
FINAL
|
PARAMETER
,
name
,
types
.
erasure
(
sym
.
type
),
translatedSym
);
ret
=
new
VarSymbol
(
(
sym
.
flags
()
&
FINAL
)
|
PARAMETER
,
name
,
types
.
erasure
(
sym
.
type
),
translatedSym
);
((
VarSymbol
)
ret
).
pos
=
((
VarSymbol
)
sym
).
pos
;
break
;
default
:
...
...
src/share/classes/com/sun/tools/javac/comp/TransTypes.java
浏览文件 @
00b7c1d1
/*
* Copyright (c) 1999, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
4
, 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
...
...
@@ -835,6 +835,8 @@ public class TransTypes extends TreeTranslator {
public
void
visitReference
(
JCMemberReference
tree
)
{
tree
.
expr
=
translate
(
tree
.
expr
,
erasure
(
tree
.
expr
.
type
));
tree
.
type
=
erasure
(
tree
.
type
);
if
(
tree
.
varargsElement
!=
null
)
tree
.
varargsElement
=
erasure
(
tree
.
varargsElement
);
result
=
tree
;
}
...
...
src/share/classes/com/sun/tools/javac/parser/JavacParser.java
浏览文件 @
00b7c1d1
...
...
@@ -161,6 +161,7 @@ public class JavacParser implements Parser {
this
.
allowStaticInterfaceMethods
=
source
.
allowStaticInterfaceMethods
();
this
.
allowIntersectionTypesInCast
=
source
.
allowIntersectionTypesInCast
();
this
.
allowTypeAnnotations
=
source
.
allowTypeAnnotations
();
this
.
allowAnnotationsAfterTypeParams
=
source
.
allowAnnotationsAfterTypeParams
();
this
.
keepDocComments
=
keepDocComments
;
docComments
=
newDocCommentTable
(
keepDocComments
,
fac
);
this
.
keepLineMap
=
keepLineMap
;
...
...
@@ -254,6 +255,10 @@ public class JavacParser implements Parser {
*/
boolean
allowTypeAnnotations
;
/** Switch: should we allow annotations after the method type parameters?
*/
boolean
allowAnnotationsAfterTypeParams
;
/** Switch: is "this" allowed as an identifier?
* This is needed to parse receiver types.
*/
...
...
@@ -2020,7 +2025,7 @@ public class JavacParser implements Parser {
/** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
*/
JCExpression
creator
(
int
newpos
,
List
<
JCExpression
>
typeArgs
)
{
List
<
JCAnnotation
>
newAnnotations
=
annotationsOpt
(
Tag
.
ANNOTATION
);
List
<
JCAnnotation
>
newAnnotations
=
typeAnnotationsOpt
(
);
switch
(
token
.
kind
)
{
case
BYTE:
case
SHORT:
case
CHAR:
case
INT:
case
LONG:
case
FLOAT:
...
...
@@ -3450,6 +3455,7 @@ public class JavacParser implements Parser {
nextToken
();
}
else
{
if
(
annosAfterParams
.
nonEmpty
())
{
checkAnnotationsAfterTypeParams
(
annosAfterParams
.
head
.
pos
);
mods
.
annotations
=
mods
.
annotations
.
appendList
(
annosAfterParams
);
if
(
mods
.
pos
==
Position
.
NOPOS
)
mods
.
pos
=
mods
.
annotations
.
head
.
pos
;
...
...
@@ -4041,6 +4047,12 @@ public class JavacParser implements Parser {
allowTypeAnnotations
=
true
;
}
}
void
checkAnnotationsAfterTypeParams
(
int
pos
)
{
if
(!
allowAnnotationsAfterTypeParams
)
{
log
.
error
(
pos
,
"annotations.after.type.params.not.supported.in.source"
,
source
.
name
);
allowAnnotationsAfterTypeParams
=
true
;
}
}
/*
* a functional source tree and end position mappings
...
...
src/share/classes/com/sun/tools/javac/resources/compiler.properties
浏览文件 @
00b7c1d1
...
...
@@ -2310,6 +2310,11 @@ compiler.err.type.annotations.not.supported.in.source=\
type annotations are not supported in -source {0}
\n\
(use -source 8 or higher to enable type annotations)
# 0: string
compiler.err.annotations.after.type.params.not.supported.in.source
=
\
annotations after method type parameters are not supported in -source {0}
\n\
(use -source 8 or higher to enable annotations after method type parameters)
# 0: string
compiler.err.repeatable.annotations.not.supported.in.source
=
\
repeated annotations are not supported in -source {0}
\n\
...
...
src/share/classes/com/sun/tools/javac/sym/Profiles.java
浏览文件 @
00b7c1d1
/*
* Copyright (c) 2006, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 201
4
, 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
...
...
@@ -153,6 +153,8 @@ public abstract class Profiles {
final
int
maxProfile
=
4
;
// Three compact profiles plus full JRE
MakefileProfiles
(
Properties
p
)
{
// consider crypto, only if java/lang package exists
boolean
foundJavaLang
=
false
;
for
(
int
profile
=
1
;
profile
<=
maxProfile
;
profile
++)
{
String
prefix
=
(
profile
<
maxProfile
?
"PROFILE_"
+
profile
:
"FULL_JRE"
);
String
inclPackages
=
p
.
getProperty
(
prefix
+
"_RTJAR_INCLUDE_PACKAGES"
);
...
...
@@ -161,6 +163,8 @@ public abstract class Profiles {
for
(
String
pkg:
inclPackages
.
substring
(
1
).
trim
().
split
(
"\\s+"
))
{
if
(
pkg
.
endsWith
(
"/"
))
pkg
=
pkg
.
substring
(
0
,
pkg
.
length
()
-
1
);
if
(
foundJavaLang
==
false
&&
pkg
.
equals
(
"java/lang"
))
foundJavaLang
=
true
;
includePackage
(
profile
,
pkg
);
}
String
inclTypes
=
p
.
getProperty
(
prefix
+
"_RTJAR_INCLUDE_TYPES"
);
...
...
@@ -178,6 +182,15 @@ public abstract class Profiles {
}
}
}
/*
* A hack to force javax/crypto package into the compact1 profile,
* because this package exists in jce.jar, and therefore not in
* ct.sym. Note javax/crypto should exist in a profile along with
* javax/net/ssl package. Thus, this package is added to compact1,
* implying that it should exist in all three profiles.
*/
if
(
foundJavaLang
)
includePackage
(
1
,
"javax/crypto"
);
}
@Override
...
...
test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.out
浏览文件 @
00b7c1d1
...
...
@@ -6,6 +6,7 @@ CantAnnotateScoping.java:47:18: compiler.err.cant.type.annotate.scoping.1: @TA
CantAnnotateScoping.java:56:37: compiler.err.cant.type.annotate.scoping: @TA,@TA2
CantAnnotateScoping.java:40:14: compiler.err.cant.type.annotate.scoping.1: @TA
CantAnnotateScoping.java:42:34: compiler.err.cant.type.annotate.scoping: @TA,@DA,@TA2
CantAnnotateScoping.java:42:25: compiler.err.annotation.type.not.applicable
CantAnnotateScoping.java:44:38: compiler.err.cant.type.annotate.scoping: @TA,@DA
CantAnnotateScoping.java:44:34: compiler.err.annotation.type.not.applicable
10 errors
\ No newline at end of file
11 errors
test/tools/javac/annotations/typeAnnotations/failures/CheckErrorsForSource7.java
0 → 100644
浏览文件 @
00b7c1d1
/*
* 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 8035890
* @summary Verify that the parser correctly checks for source level 8 on the new places where
* annotations can appear in 8.
* @run main CheckErrorsForSource7 CheckErrorsForSource7.java
*/
import
java.io.File
;
import
java.io.IOException
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Target
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
javax.tools.Diagnostic
;
import
javax.tools.DiagnosticCollector
;
import
javax.tools.JavaFileObject
;
import
javax.tools.SimpleJavaFileObject
;
import
com.sun.source.tree.AnnotationTree
;
import
com.sun.source.tree.CompilationUnitTree
;
import
com.sun.source.tree.IdentifierTree
;
import
com.sun.source.tree.Tree.Kind
;
import
com.sun.source.util.JavacTask
;
import
com.sun.source.util.TreePathScanner
;
import
com.sun.source.util.Trees
;
import
com.sun.tools.javac.api.JavacTool
;
import
com.sun.tools.javac.file.JavacFileManager
;
/**For each place where an annotation can syntactically appear with -source 8, but not with
* -source 7, this test verifies that an error is correctly emitted from the parser for
* the annotation for -source 7. This test first gathers the occurrences of @TA from
* the CheckErrorsForSource7Data class below, and then repeatedly removes all these annotations
* except one and checks the parser reports an expected error. This is needed as as the parser
* typically produces only one 'insufficient source level' error for each new feature used.
*/
public
class
CheckErrorsForSource7
{
public
static
void
main
(
String
...
args
)
throws
IOException
,
URISyntaxException
{
new
CheckErrorsForSource7
().
run
(
args
);
}
private
void
run
(
String
...
args
)
throws
IOException
,
URISyntaxException
{
//the first and only parameter must be the name of the file to be analyzed:
if
(
args
.
length
!=
1
)
throw
new
IllegalStateException
(
"Must provide source file!"
);
File
testSrc
=
new
File
(
System
.
getProperty
(
"test.src"
));
File
testFile
=
new
File
(
testSrc
,
args
[
0
]);
if
(!
testFile
.
canRead
())
throw
new
IllegalStateException
(
"Cannot read the test source"
);
JavacFileManager
fm
=
JavacTool
.
create
().
getStandardFileManager
(
null
,
null
,
null
);
//gather spans of the @TA annotations into typeAnnotationSpans:
JavacTask
task
=
JavacTool
.
create
().
getTask
(
null
,
fm
,
null
,
Collections
.<
String
>
emptyList
(),
null
,
fm
.
getJavaFileObjects
(
testFile
));
final
Trees
trees
=
Trees
.
instance
(
task
);
final
CompilationUnitTree
cut
=
task
.
parse
().
iterator
().
next
();
final
List
<
int
[]>
typeAnnotationSpans
=
new
ArrayList
<>();
new
TreePathScanner
<
Void
,
Void
>()
{
@Override
public
Void
visitAnnotation
(
AnnotationTree
node
,
Void
p
)
{
if
(
node
.
getAnnotationType
().
getKind
()
==
Kind
.
IDENTIFIER
&&
((
IdentifierTree
)
node
.
getAnnotationType
()).
getName
().
contentEquals
(
"TA"
))
{
int
start
=
(
int
)
trees
.
getSourcePositions
().
getStartPosition
(
cut
,
node
);
int
end
=
(
int
)
trees
.
getSourcePositions
().
getEndPosition
(
cut
,
node
);
typeAnnotationSpans
.
add
(
new
int
[]
{
start
,
end
});
}
return
null
;
}
}.
scan
(
cut
,
null
);
//sort the spans in the reverse order, to simplify removing them from the source:
Collections
.
sort
(
typeAnnotationSpans
,
new
Comparator
<
int
[]>()
{
@Override
public
int
compare
(
int
[]
o1
,
int
[]
o2
)
{
return
o2
[
0
]
-
o1
[
0
];
}
});
//verify the errors are produce correctly:
String
originalSource
=
cut
.
getSourceFile
().
getCharContent
(
false
).
toString
();
for
(
int
[]
toKeep
:
typeAnnotationSpans
)
{
//prepare updated source code by removing all the annotations except the toKeep one:
String
updated
=
originalSource
;
for
(
int
[]
span
:
typeAnnotationSpans
)
{
if
(
span
==
toKeep
)
continue
;
updated
=
updated
.
substring
(
0
,
span
[
0
])
+
updated
.
substring
(
span
[
1
]);
}
//parse and verify:
JavaFileObject
updatedFile
=
new
TestFO
(
cut
.
getSourceFile
().
toUri
(),
updated
);
DiagnosticCollector
<
JavaFileObject
>
errors
=
new
DiagnosticCollector
<>();
JavacTask
task2
=
JavacTool
.
create
().
getTask
(
null
,
fm
,
errors
,
Arrays
.
asList
(
"-source"
,
"7"
),
null
,
Arrays
.
asList
(
updatedFile
));
task2
.
parse
();
boolean
found
=
false
;
for
(
Diagnostic
<?
extends
JavaFileObject
>
d
:
errors
.
getDiagnostics
())
{
if
(
d
.
getKind
()
==
Diagnostic
.
Kind
.
ERROR
&&
EXPECTED_ERRORS
.
contains
(
d
.
getCode
()))
{
if
(
found
)
{
throw
new
IllegalStateException
(
"More than one expected error found."
);
}
found
=
true
;
}
}
if
(!
found
)
throw
new
IllegalStateException
(
"Did not produce proper errors for: "
+
updated
);
}
}
static
final
Set
<
String
>
EXPECTED_ERRORS
=
new
HashSet
<>(
Arrays
.
asList
(
"compiler.err.type.annotations.not.supported.in.source"
,
"compiler.err.annotations.after.type.params.not.supported.in.source"
));
class
TestFO
extends
SimpleJavaFileObject
{
private
final
String
content
;
public
TestFO
(
URI
uri
,
String
content
)
{
super
(
uri
,
Kind
.
SOURCE
);
this
.
content
=
content
;
}
@Override
public
CharSequence
getCharContent
(
boolean
ignoreEncodingErrors
)
throws
IOException
{
return
content
;
}
@Override
public
boolean
isNameCompatible
(
String
simpleName
,
Kind
kind
)
{
return
true
;
}
}
}
//data on which the source level check is verified:
class
CheckErrorsForSource7Data
{
@Target
(
ElementType
.
TYPE_USE
)
@interface
TA
{
}
Object
n1
=
new
@TA
ArrayList
<
@TA
String
>();
Object
n2
=
new
@TA
Object
()
{};
Object
[]
@TA
[]
arr
@TA
[];
<
T
>
@TA
int
@TA
[]
ret
(
Object
obj
)
@TA
[]
throws
@TA
Exception
{
this
.<
@TA
String
>
ret
(
null
);
Object
c1
=
new
@TA
String
[
1
];
int
val
=
obj
instanceof
@TA
String
?
((
@TA
String
)
obj
).
length
()
:
0
;
List
<
@TA
?>
l
;
return
null
;
}
void
vararg
(
String
@TA
...
args
)
{
}
abstract
class
C
<
@TA
T
extends
@TA
Number
&
@TA
Runnable
>
extends
@TA
ArrayList
<
@TA
String
>
implements
java
.
util
.
@TA
Comparator
<
@TA
T
>
{
}
interface
I
extends
java
.
util
.
@TA
Comparator
<
@TA
String
>
{
}
}
test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out
浏览文件 @
00b7c1d1
DeclarationAnnotation.java:13:21: compiler.err.annotation.type.not.applicable
DeclarationAnnotation.java:10:21: compiler.err.annotation.type.not.applicable
DeclarationAnnotation.java:11:21: compiler.err.annotation.type.not.applicable
DeclarationAnnotation.java:12:21: compiler.err.annotation.type.not.applicable
DeclarationAnnotation.java:13:21: compiler.err.annotation.type.not.applicable
4 errors
test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java
浏览文件 @
00b7c1d1
/*
* Copyright (c) 2012, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 201
4
, 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
...
...
@@ -26,6 +26,7 @@
* @bug 8005166
* @summary Add support for static interface methods
* Smoke test for static interface method hiding
* @run main/timeout=600 InterfaceMethodHidingTest
*/
import
com.sun.source.util.JavacTask
;
...
...
test/tools/javac/diags/examples/AnnotationsAfterTypeParamsNotSupportedInSource.java
0 → 100644
浏览文件 @
00b7c1d1
/*
* 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.
*/
// key: compiler.err.annotations.after.type.params.not.supported.in.source
// key: compiler.warn.source.no.bootclasspath
// options: -source 7
@interface
Anno
{
}
class
AnnotationsAfterTypeParamsNotSupportedInSource
{
<
T
>
@Anno
int
m
()
{
return
0
;
}
}
test/tools/javac/lambda/FunctionalInterfaceConversionTest.java
浏览文件 @
00b7c1d1
/*
* Copyright (c) 2012, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 201
4
, 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
...
...
@@ -30,7 +30,7 @@
* @author Maurizio Cimadamore
* @library ../lib
* @build JavacTestingAbstractThreadedTest
* @run main/othervm FunctionalInterfaceConversionTest
* @run main/
timeout=600/
othervm FunctionalInterfaceConversionTest
*/
// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
...
...
test/tools/javac/lambda/T8037935/LambdaWithBinOpConstRefToConstString.java
0 → 100644
浏览文件 @
00b7c1d1
/*
* 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 8037935
* @summary Javac: final local String var referenced in binary/unary op in lambda produces code that does not verify
* @run main LambdaWithBinOpConstRefToConstString
*/
interface
MyFI
{
void
accept
();
}
public
class
LambdaWithBinOpConstRefToConstString
{
public
static
void
main
(
String
[]
args
)
{
final
String
CONSTANT_STRING_VALUE
=
"mwmwm"
;
MyFI
consumeStrings
=
()
->
{
System
.
out
.
println
(
" local constant: "
+
CONSTANT_STRING_VALUE
);
};
}
}
test/tools/javac/lambda/T8038420/LambdaIncrement.java
0 → 100644
浏览文件 @
00b7c1d1
/*
* 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 8038420
* @summary Lambda returning post-increment generates wrong code
* @run main LambdaIncrement
*/
public
class
LambdaIncrement
{
interface
IntegerOp
{
Integer
apply
(
Integer
arg
);
}
private
static
void
assertNotIncremented
(
IntegerOp
lmb
,
String
label
)
{
int
result
=
lmb
.
apply
(
3
);
if
(
result
!=
3
)
{
throw
new
AssertionError
(
"Post-increment failure. Expected 3, got: "
+
result
+
" "
+
label
);
}
}
public
static
void
main
(
String
...
args
)
throws
Exception
{
assertNotIncremented
(
x
->
x
++,
"PostIncExpr"
);
assertNotIncremented
(
x
->
{
return
x
++;
},
"PostIncReturn"
);
assertNotIncremented
(
x
->
{
int
y
=
x
;
return
y
++;
},
"PostIncLocal"
);
assertNotIncremented
(
x
->
{
Integer
y
=
x
;
return
y
++;
},
"PostIncLocalBox"
);
assertNotIncremented
(
x
->
{
int
y
=
x
;
return
y
;
},
"HASINIT"
);
}
}
test/tools/javac/varargs/MethodHandleCrash.java
0 → 100644
浏览文件 @
00b7c1d1
/*
* 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 8034048
* @summary javac crash with method references plus lambda plus var args
* @author govereau
*
* @compile MethodHandleCrash.java
*/
public
interface
MethodHandleCrash
{
static
<
T
>
void
functional
(
T
...
input
)
{
java
.
util
.
function
.
Consumer
<
T
>
c
=
MethodHandleCrash:
:
functional
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录