Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
b2d675c5
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看板
提交
b2d675c5
编写于
2月 24, 2009
作者:
D
darcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6498938: Faulty comparison of TypeMirror objects in getElementsAnnotatedWith implementation
Reviewed-by: jjg
上级
4b2b9aeb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
7 deletion
+77
-7
src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java
...com/sun/tools/javac/processing/JavacRoundEnvironment.java
+7
-4
test/tools/javac/processing/environment/round/Foo.java
test/tools/javac/processing/environment/round/Foo.java
+27
-0
test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java
...ocessing/environment/round/TestElementsAnnotatedWith.java
+43
-3
未找到文件。
src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java
浏览文件 @
b2d675c5
/*
* Copyright 2005-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2005-200
9
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
...
...
@@ -111,6 +111,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
*/
public
Set
<?
extends
Element
>
getElementsAnnotatedWith
(
TypeElement
a
)
{
Set
<
Element
>
result
=
Collections
.
emptySet
();
Types
typeUtil
=
processingEnv
.
getTypeUtils
();
if
(
a
.
getKind
()
!=
ElementKind
.
ANNOTATION_TYPE
)
throw
new
IllegalArgumentException
(
NOT_AN_ANNOTATION_TYPE
+
a
);
...
...
@@ -122,7 +123,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
throw
new
AssertionError
(
"Bad implementation type for "
+
tm
);
ElementScanner6
<
Set
<
Element
>,
DeclaredType
>
scanner
=
new
AnnotationSetScanner
(
result
);
new
AnnotationSetScanner
(
result
,
typeUtil
);
for
(
Element
element
:
rootElements
)
result
=
scanner
.
scan
(
element
,
annotationTypeElement
);
...
...
@@ -135,9 +136,11 @@ public class JavacRoundEnvironment implements RoundEnvironment {
ElementScanner6
<
Set
<
Element
>,
DeclaredType
>
{
// Insertion-order preserving set
Set
<
Element
>
annotatedElements
=
new
LinkedHashSet
<
Element
>();
Types
typeUtil
;
AnnotationSetScanner
(
Set
<
Element
>
defaultSet
)
{
AnnotationSetScanner
(
Set
<
Element
>
defaultSet
,
Types
typeUtil
)
{
super
(
defaultSet
);
this
.
typeUtil
=
typeUtil
;
}
@Override
...
...
@@ -145,7 +148,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
java
.
util
.
List
<?
extends
AnnotationMirror
>
annotationMirrors
=
processingEnv
.
getElementUtils
().
getAllAnnotationMirrors
(
e
);
for
(
AnnotationMirror
annotationMirror
:
annotationMirrors
)
{
if
(
annotationMirror
.
getAnnotationType
().
equals
(
p
))
if
(
typeUtil
.
isSameType
(
annotationMirror
.
getAnnotationType
(),
p
))
annotatedElements
.
add
(
e
);
}
e
.
accept
(
this
,
p
);
...
...
test/tools/javac/processing/environment/round/Foo.java
0 → 100644
浏览文件 @
b2d675c5
/*
* Copyright 2006 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.
*/
@AnnotatedElementInfo
(
annotationName
=
"AnnotatedElementInfo"
,
expectedSize
=
1
,
names
=
"Foo"
)
public
class
Foo
{}
test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java
浏览文件 @
b2d675c5
/*
* Copyright 2006-200
7
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2006-200
9
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
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 6397298 6400986 6425592 6449798 6453386 6508401
* @bug 6397298 6400986 6425592 6449798 6453386 6508401
6498938
* @summary Tests that getElementsAnnotatedWith works properly.
* @author Joseph D. Darcy
* @compile TestElementsAnnotatedWith.java
...
...
@@ -31,16 +31,22 @@
* @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java
* @compile -processor TestElementsAnnotatedWith -proc:only TestElementsAnnotatedWith.java
* @compile -processor TestElementsAnnotatedWith -proc:only C2.java
* @compile -processor TestElementsAnnotatedWith -proc:only Foo.java
* @compile -XD-d=. Foo.java
* @compile -processor TestElementsAnnotatedWith -proc:only TestElementsAnnotatedWith.java
*/
import
java.lang.annotation.Annotation
;
import
java.io.*
;
import
java.util.Collections
;
import
java.util.Set
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
javax.annotation.processing.*
;
import
javax.tools.*
;
import
javax.lang.model.SourceVersion
;
import
javax.lang.model.element.*
;
import
javax.lang.model.util.*
;
...
...
@@ -120,6 +126,9 @@ public class TestElementsAnnotatedWith extends AbstractProcessor {
System
.
err
.
println
(
"AnnotatedElementInfo: "
+
annotatedElementInfo
);
throw
new
RuntimeException
();
}
if
(
"TestElementsAnnotatedWith"
.
equals
(
firstType
.
getSimpleName
().
toString
()))
writeClassFile
();
// Start another round to test class file input
}
else
{
// If processing is over without an error, the specified
// elements should be empty so an empty set should be returned.
...
...
@@ -161,6 +170,37 @@ public class TestElementsAnnotatedWith extends AbstractProcessor {
}
catch
(
IllegalArgumentException
iae
)
{}
}
/*
* Hack alert! The class file read below is generated by the
* "@compile -XD-d=. Foo.java" directive above. This sneakily
* overrides the output location to the current directory where a
* subsequent @compile can read the file. This could be improved
* if either a new directive like @process accepted class file
* arguments (the javac command accepts such arguments but
* @compile does not) or the test.src and test.classes properties
* were set to be read with @compile jobs.
*/
private
void
writeClassFile
()
{
try
{
Filer
filer
=
processingEnv
.
getFiler
();
JavaFileObject
jfo
=
filer
.
createClassFile
(
"Foo"
);
OutputStream
os
=
jfo
.
openOutputStream
();
// Copy the bytes over
System
.
out
.
println
((
new
File
(
"."
)).
getAbsolutePath
());
InputStream
io
=
new
BufferedInputStream
(
new
FileInputStream
(
new
File
(
"."
,
"Foo.class"
)));
int
datum
=
io
.
read
();
while
(
datum
!=
-
1
)
{
os
.
write
(
datum
);
datum
=
io
.
read
();
}
os
.
close
();
}
catch
(
IOException
io
)
{
throw
new
RuntimeException
(
io
);
}
}
@Override
public
SourceVersion
getSupportedSourceVersion
()
{
return
SourceVersion
.
latest
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录