Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a82f5510
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a82f5510
编写于
11月 07, 2013
作者:
J
jfranck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8027796: Refactor Core Reflection for Type Annotations
Reviewed-by: psandoz
上级
fc73eb55
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
22 deletion
+24
-22
src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java
.../classes/sun/reflect/annotation/AnnotatedTypeFactory.java
+17
-16
src/share/classes/sun/reflect/annotation/TypeAnnotation.java
src/share/classes/sun/reflect/annotation/TypeAnnotation.java
+5
-4
src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java
.../classes/sun/reflect/annotation/TypeAnnotationParser.java
+2
-2
未找到文件。
src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java
浏览文件 @
a82f5510
...
@@ -34,7 +34,7 @@ import java.util.Map;
...
@@ -34,7 +34,7 @@ import java.util.Map;
import
static
sun
.
reflect
.
annotation
.
TypeAnnotation
.*;
import
static
sun
.
reflect
.
annotation
.
TypeAnnotation
.*;
public
class
AnnotatedTypeFactory
{
public
final
class
AnnotatedTypeFactory
{
/**
/**
* Create an AnnotatedType.
* Create an AnnotatedType.
*
*
...
@@ -47,10 +47,10 @@ public class AnnotatedTypeFactory {
...
@@ -47,10 +47,10 @@ public class AnnotatedTypeFactory {
* corresponds to
* corresponds to
*/
*/
public
static
AnnotatedType
buildAnnotatedType
(
Type
type
,
public
static
AnnotatedType
buildAnnotatedType
(
Type
type
,
LocationInfo
currentLoc
,
LocationInfo
currentLoc
,
TypeAnnotation
[]
actualTypeAnnos
,
TypeAnnotation
[]
actualTypeAnnos
,
TypeAnnotation
[]
allOnSameTarget
,
TypeAnnotation
[]
allOnSameTarget
,
AnnotatedElement
decl
)
{
AnnotatedElement
decl
)
{
if
(
type
==
null
)
{
if
(
type
==
null
)
{
return
EMPTY_ANNOTATED_TYPE
;
return
EMPTY_ANNOTATED_TYPE
;
}
}
...
@@ -156,40 +156,40 @@ public class AnnotatedTypeFactory {
...
@@ -156,40 +156,40 @@ public class AnnotatedTypeFactory {
}
}
@Override
@Override
public
Annotation
[]
getDeclaredAnnotations
()
{
public
final
Annotation
[]
getDeclaredAnnotations
()
{
return
annotations
.
values
().
toArray
(
new
Annotation
[
0
]);
return
annotations
.
values
().
toArray
(
new
Annotation
[
0
]);
}
}
@Override
@Override
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
<
T
extends
Annotation
>
T
getDeclaredAnnotation
(
Class
<
T
>
annotation
)
{
public
final
<
T
extends
Annotation
>
T
getDeclaredAnnotation
(
Class
<
T
>
annotation
)
{
return
(
T
)
annotations
.
get
(
annotation
);
return
(
T
)
annotations
.
get
(
annotation
);
}
}
@Override
@Override
public
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotationsByType
(
Class
<
T
>
annotation
)
{
public
final
<
T
extends
Annotation
>
T
[]
getDeclaredAnnotationsByType
(
Class
<
T
>
annotation
)
{
return
AnnotationSupport
.
getDirectlyAndIndirectlyPresent
(
annotations
,
annotation
);
return
AnnotationSupport
.
getDirectlyAndIndirectlyPresent
(
annotations
,
annotation
);
}
}
// AnnotatedType
// AnnotatedType
@Override
@Override
public
Type
getType
()
{
public
final
Type
getType
()
{
return
type
;
return
type
;
}
}
// Implementation details
// Implementation details
LocationInfo
getLocation
()
{
final
LocationInfo
getLocation
()
{
return
location
;
return
location
;
}
}
TypeAnnotation
[]
getTypeAnnotations
()
{
final
TypeAnnotation
[]
getTypeAnnotations
()
{
return
allOnSameTargetTypeAnnotations
;
return
allOnSameTargetTypeAnnotations
;
}
}
AnnotatedElement
getDecl
()
{
final
AnnotatedElement
getDecl
()
{
return
decl
;
return
decl
;
}
}
}
}
private
static
class
AnnotatedArrayTypeImpl
extends
AnnotatedTypeBaseImpl
implements
AnnotatedArrayType
{
private
static
final
class
AnnotatedArrayTypeImpl
extends
AnnotatedTypeBaseImpl
implements
AnnotatedArrayType
{
AnnotatedArrayTypeImpl
(
Type
type
,
LocationInfo
location
,
AnnotatedArrayTypeImpl
(
Type
type
,
LocationInfo
location
,
TypeAnnotation
[]
actualTypeAnnotations
,
TypeAnnotation
[]
allOnSameTargetTypeAnnotations
,
TypeAnnotation
[]
actualTypeAnnotations
,
TypeAnnotation
[]
allOnSameTargetTypeAnnotations
,
AnnotatedElement
decl
)
{
AnnotatedElement
decl
)
{
...
@@ -215,7 +215,7 @@ public class AnnotatedTypeFactory {
...
@@ -215,7 +215,7 @@ public class AnnotatedTypeFactory {
}
}
}
}
private
static
class
AnnotatedTypeVariableImpl
extends
AnnotatedTypeBaseImpl
implements
AnnotatedTypeVariable
{
private
static
final
class
AnnotatedTypeVariableImpl
extends
AnnotatedTypeBaseImpl
implements
AnnotatedTypeVariable
{
AnnotatedTypeVariableImpl
(
TypeVariable
<?>
type
,
LocationInfo
location
,
AnnotatedTypeVariableImpl
(
TypeVariable
<?>
type
,
LocationInfo
location
,
TypeAnnotation
[]
actualTypeAnnotations
,
TypeAnnotation
[]
allOnSameTargetTypeAnnotations
,
TypeAnnotation
[]
actualTypeAnnotations
,
TypeAnnotation
[]
allOnSameTargetTypeAnnotations
,
AnnotatedElement
decl
)
{
AnnotatedElement
decl
)
{
...
@@ -232,7 +232,8 @@ public class AnnotatedTypeFactory {
...
@@ -232,7 +232,8 @@ public class AnnotatedTypeFactory {
}
}
}
}
private
static
class
AnnotatedParameterizedTypeImpl
extends
AnnotatedTypeBaseImpl
implements
AnnotatedParameterizedType
{
private
static
final
class
AnnotatedParameterizedTypeImpl
extends
AnnotatedTypeBaseImpl
implements
AnnotatedParameterizedType
{
AnnotatedParameterizedTypeImpl
(
ParameterizedType
type
,
LocationInfo
location
,
AnnotatedParameterizedTypeImpl
(
ParameterizedType
type
,
LocationInfo
location
,
TypeAnnotation
[]
actualTypeAnnotations
,
TypeAnnotation
[]
allOnSameTargetTypeAnnotations
,
TypeAnnotation
[]
actualTypeAnnotations
,
TypeAnnotation
[]
allOnSameTargetTypeAnnotations
,
AnnotatedElement
decl
)
{
AnnotatedElement
decl
)
{
...
@@ -265,7 +266,7 @@ public class AnnotatedTypeFactory {
...
@@ -265,7 +266,7 @@ public class AnnotatedTypeFactory {
}
}
}
}
private
static
class
AnnotatedWildcardTypeImpl
extends
AnnotatedTypeBaseImpl
implements
AnnotatedWildcardType
{
private
static
final
class
AnnotatedWildcardTypeImpl
extends
AnnotatedTypeBaseImpl
implements
AnnotatedWildcardType
{
private
final
boolean
hasUpperBounds
;
private
final
boolean
hasUpperBounds
;
AnnotatedWildcardTypeImpl
(
WildcardType
type
,
LocationInfo
location
,
AnnotatedWildcardTypeImpl
(
WildcardType
type
,
LocationInfo
location
,
TypeAnnotation
[]
actualTypeAnnotations
,
TypeAnnotation
[]
allOnSameTargetTypeAnnotations
,
TypeAnnotation
[]
actualTypeAnnotations
,
TypeAnnotation
[]
allOnSameTargetTypeAnnotations
,
...
...
src/share/classes/sun/reflect/annotation/TypeAnnotation.java
浏览文件 @
a82f5510
...
@@ -40,7 +40,7 @@ import java.util.List;
...
@@ -40,7 +40,7 @@ import java.util.List;
* distinguish between '@A Inner.@B Outer' in for example nested types),
* distinguish between '@A Inner.@B Outer' in for example nested types),
* target info and the declaration the TypeAnnotaiton was parsed from.
* target info and the declaration the TypeAnnotaiton was parsed from.
*/
*/
public
class
TypeAnnotation
{
public
final
class
TypeAnnotation
{
private
final
TypeAnnotationTargetInfo
targetInfo
;
private
final
TypeAnnotationTargetInfo
targetInfo
;
private
final
LocationInfo
loc
;
private
final
LocationInfo
loc
;
private
final
Annotation
annotation
;
private
final
Annotation
annotation
;
...
@@ -92,7 +92,8 @@ public class TypeAnnotation {
...
@@ -92,7 +92,8 @@ public class TypeAnnotation {
METHOD_FORMAL_PARAMETER
,
METHOD_FORMAL_PARAMETER
,
THROWS
;
THROWS
;
}
}
public
static
class
TypeAnnotationTargetInfo
{
public
static
final
class
TypeAnnotationTargetInfo
{
private
final
TypeAnnotationTarget
target
;
private
final
TypeAnnotationTarget
target
;
private
final
int
count
;
private
final
int
count
;
private
final
int
secondaryIndex
;
private
final
int
secondaryIndex
;
...
@@ -131,7 +132,7 @@ public class TypeAnnotation {
...
@@ -131,7 +132,7 @@ public class TypeAnnotation {
}
}
}
}
public
static
class
LocationInfo
{
public
static
final
class
LocationInfo
{
private
final
int
depth
;
private
final
int
depth
;
private
final
Location
[]
locations
;
private
final
Location
[]
locations
;
...
@@ -204,7 +205,7 @@ public class TypeAnnotation {
...
@@ -204,7 +205,7 @@ public class TypeAnnotation {
return
true
;
return
true
;
}
}
public
static
class
Location
{
public
static
final
class
Location
{
public
final
byte
tag
;
public
final
byte
tag
;
public
final
byte
index
;
public
final
byte
index
;
...
...
src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java
浏览文件 @
a82f5510
...
@@ -43,7 +43,7 @@ import static sun.reflect.annotation.TypeAnnotation.*;
...
@@ -43,7 +43,7 @@ import static sun.reflect.annotation.TypeAnnotation.*;
* TypeAnnotationParser implements the logic needed to parse
* TypeAnnotationParser implements the logic needed to parse
* TypeAnnotations from an array of bytes.
* TypeAnnotations from an array of bytes.
*/
*/
public
class
TypeAnnotationParser
{
public
final
class
TypeAnnotationParser
{
private
static
final
TypeAnnotation
[]
EMPTY_TYPE_ANNOTATION_ARRAY
=
new
TypeAnnotation
[
0
];
private
static
final
TypeAnnotation
[]
EMPTY_TYPE_ANNOTATION_ARRAY
=
new
TypeAnnotation
[
0
];
/**
/**
...
@@ -237,7 +237,7 @@ public class TypeAnnotationParser {
...
@@ -237,7 +237,7 @@ public class TypeAnnotationParser {
return
parseAnnotatedBounds
(
bounds
,
decl
,
typeVarIndex
,
LocationInfo
.
BASE_LOCATION
);
return
parseAnnotatedBounds
(
bounds
,
decl
,
typeVarIndex
,
LocationInfo
.
BASE_LOCATION
);
}
}
//helper for above
//helper for above
static
<
D
extends
GenericDeclaration
>
AnnotatedType
[]
parseAnnotatedBounds
(
Type
[]
bounds
,
private
static
<
D
extends
GenericDeclaration
>
AnnotatedType
[]
parseAnnotatedBounds
(
Type
[]
bounds
,
D
decl
,
D
decl
,
int
typeVarIndex
,
int
typeVarIndex
,
LocationInfo
loc
)
{
LocationInfo
loc
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录