Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
8ab4b652
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看板
提交
8ab4b652
编写于
10月 06, 2009
作者:
D
darcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
5062288: (reflect) Core reflection uses raw types when it could be using wildcards
Reviewed-by: alanb
上级
ca754cfe
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
168 addition
and
166 deletion
+168
-166
src/share/classes/java/lang/Class.java
src/share/classes/java/lang/Class.java
+35
-35
src/share/classes/java/lang/Package.java
src/share/classes/java/lang/Package.java
+1
-1
src/share/classes/java/lang/reflect/AccessibleObject.java
src/share/classes/java/lang/reflect/AccessibleObject.java
+1
-1
src/share/classes/java/lang/reflect/Constructor.java
src/share/classes/java/lang/reflect/Constructor.java
+14
-14
src/share/classes/java/lang/reflect/Field.java
src/share/classes/java/lang/reflect/Field.java
+14
-14
src/share/classes/java/lang/reflect/Method.java
src/share/classes/java/lang/reflect/Method.java
+21
-21
src/share/classes/java/lang/reflect/Proxy.java
src/share/classes/java/lang/reflect/Proxy.java
+2
-2
src/share/classes/java/lang/reflect/ReflectAccess.java
src/share/classes/java/lang/reflect/ReflectAccess.java
+14
-14
src/share/classes/sun/reflect/LangReflectAccess.java
src/share/classes/sun/reflect/LangReflectAccess.java
+14
-14
src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
...s/sun/reflect/annotation/AnnotationInvocationHandler.java
+9
-9
src/share/classes/sun/reflect/annotation/AnnotationParser.java
...hare/classes/sun/reflect/annotation/AnnotationParser.java
+36
-34
src/share/classes/sun/reflect/annotation/AnnotationType.java
src/share/classes/sun/reflect/annotation/AnnotationType.java
+7
-7
未找到文件。
src/share/classes/java/lang/Class.java
浏览文件 @
8ab4b652
...
...
@@ -265,7 +265,7 @@ public final
}
/** Called after security checks have been made. */
private
static
native
Class
forName0
(
String
name
,
boolean
initialize
,
private
static
native
Class
<?>
forName0
(
String
name
,
boolean
initialize
,
ClassLoader
loader
)
throws
ClassNotFoundException
;
...
...
@@ -339,7 +339,7 @@ public final
);
}
try
{
Class
[]
empty
=
{};
Class
<?>
[]
empty
=
{};
final
Constructor
<
T
>
c
=
getConstructor0
(
empty
,
Member
.
DECLARED
);
// Disable accessibility checks on the constructor
// since we have to do the security check here anyway
...
...
@@ -361,7 +361,7 @@ public final
// Security check (same as in java.lang.reflect.Constructor)
int
modifiers
=
tmpConstructor
.
getModifiers
();
if
(!
Reflection
.
quickCheckMemberAccess
(
this
,
modifiers
))
{
Class
caller
=
Reflection
.
getCallerClass
(
3
);
Class
<?>
caller
=
Reflection
.
getCallerClass
(
3
);
if
(
newInstanceCallerCache
!=
caller
)
{
Reflection
.
ensureMemberAccess
(
caller
,
this
,
null
,
modifiers
);
newInstanceCallerCache
=
caller
;
...
...
@@ -377,7 +377,7 @@ public final
}
}
private
volatile
transient
Constructor
<
T
>
cachedConstructor
;
private
volatile
transient
Class
newInstanceCallerCache
;
private
volatile
transient
Class
<?>
newInstanceCallerCache
;
/**
...
...
@@ -638,7 +638,7 @@ public final
if
(
getGenericSignature
()
!=
null
)
return
(
TypeVariable
<
Class
<
T
>>[])
getGenericInfo
().
getTypeParameters
();
else
return
(
TypeVariable
<
Class
<
T
>>[])
new
TypeVariable
[
0
];
return
(
TypeVariable
<
Class
<
T
>>[])
new
TypeVariable
<?>
[
0
];
}
...
...
@@ -901,7 +901,7 @@ public final
MethodRepository
typeInfo
=
MethodRepository
.
make
(
enclosingInfo
.
getDescriptor
(),
getFactory
());
Class
returnType
=
toClass
(
typeInfo
.
getReturnType
());
Class
<?>
returnType
=
toClass
(
typeInfo
.
getReturnType
());
Type
[]
parameterTypes
=
typeInfo
.
getParameterTypes
();
Class
<?>[]
parameterClasses
=
new
Class
<?>[
parameterTypes
.
length
];
...
...
@@ -996,12 +996,12 @@ public final
}
private
static
Class
toClass
(
Type
o
)
{
private
static
Class
<?>
toClass
(
Type
o
)
{
if
(
o
instanceof
GenericArrayType
)
return
Array
.
newInstance
(
toClass
(((
GenericArrayType
)
o
).
getGenericComponentType
()),
0
)
.
getClass
();
return
(
Class
)
o
;
return
(
Class
<?>
)
o
;
}
/**
...
...
@@ -1042,7 +1042,7 @@ public final
* Loop over all declared constructors; match number
* of and type of parameters.
*/
for
(
Constructor
c:
enclosingInfo
.
getEnclosingClass
().
getDeclaredConstructors
())
{
for
(
Constructor
<?>
c:
enclosingInfo
.
getEnclosingClass
().
getDeclaredConstructors
())
{
Class
<?>[]
candidateParamClasses
=
c
.
getParameterTypes
();
if
(
candidateParamClasses
.
length
==
parameterClasses
.
length
)
{
boolean
matches
=
true
;
...
...
@@ -1304,12 +1304,12 @@ public final
// has already been ok'd by the SecurityManager.
return
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
<
Class
[]>()
{
new
java
.
security
.
PrivilegedAction
<
Class
<?>
[]>()
{
public
Class
[]
run
()
{
List
<
Class
>
list
=
new
ArrayList
<
Class
>();
Class
currentClass
=
Class
.
this
;
List
<
Class
<?>>
list
=
new
ArrayList
<
Class
<?>
>();
Class
<?>
currentClass
=
Class
.
this
;
while
(
currentClass
!=
null
)
{
Class
[]
members
=
currentClass
.
getDeclaredClasses
();
Class
<?>
[]
members
=
currentClass
.
getDeclaredClasses
();
for
(
int
i
=
0
;
i
<
members
.
length
;
i
++)
{
if
(
Modifier
.
isPublic
(
members
[
i
].
getModifiers
()))
{
list
.
add
(
members
[
i
]);
...
...
@@ -2191,7 +2191,7 @@ public final
return
name
;
}
if
(!
name
.
startsWith
(
"/"
))
{
Class
c
=
this
;
Class
<?>
c
=
this
;
while
(
c
.
isArray
())
{
c
=
c
.
getComponentType
();
}
...
...
@@ -2565,12 +2565,12 @@ public final
// out concrete implementations inherited from superclasses at
// the end.
MethodArray
inheritedMethods
=
new
MethodArray
();
Class
[]
interfaces
=
getInterfaces
();
Class
<?>
[]
interfaces
=
getInterfaces
();
for
(
int
i
=
0
;
i
<
interfaces
.
length
;
i
++)
{
inheritedMethods
.
addAll
(
interfaces
[
i
].
privateGetPublicMethods
());
}
if
(!
isInterface
())
{
Class
c
=
getSuperclass
();
Class
<?>
c
=
getSuperclass
();
if
(
c
!=
null
)
{
MethodArray
supers
=
new
MethodArray
();
supers
.
addAll
(
c
.
privateGetPublicMethods
());
...
...
@@ -2632,16 +2632,16 @@ public final
return
res
;
}
// Direct superinterfaces, recursively
Class
[]
interfaces
=
getInterfaces
();
Class
<?>
[]
interfaces
=
getInterfaces
();
for
(
int
i
=
0
;
i
<
interfaces
.
length
;
i
++)
{
Class
c
=
interfaces
[
i
];
Class
<?>
c
=
interfaces
[
i
];
if
((
res
=
c
.
getField0
(
name
))
!=
null
)
{
return
res
;
}
}
// Direct superclass, recursively
if
(!
isInterface
())
{
Class
c
=
getSuperclass
();
Class
<?>
c
=
getSuperclass
();
if
(
c
!=
null
)
{
if
((
res
=
c
.
getField0
(
name
))
!=
null
)
{
return
res
;
...
...
@@ -2653,7 +2653,7 @@ public final
private
static
Method
searchMethods
(
Method
[]
methods
,
String
name
,
Class
[]
parameterTypes
)
Class
<?>
[]
parameterTypes
)
{
Method
res
=
null
;
String
internedName
=
name
.
intern
();
...
...
@@ -2670,7 +2670,7 @@ public final
}
private
Method
getMethod0
(
String
name
,
Class
[]
parameterTypes
)
{
private
Method
getMethod0
(
String
name
,
Class
<?>
[]
parameterTypes
)
{
// Note: the intent is that the search algorithm this routine
// uses be equivalent to the ordering imposed by
// privateGetPublicMethods(). It fetches only the declared
...
...
@@ -2687,7 +2687,7 @@ public final
}
// Search superclass's methods
if
(!
isInterface
())
{
Class
c
=
getSuperclass
();
Class
<?
super
T
>
c
=
getSuperclass
();
if
(
c
!=
null
)
{
if
((
res
=
c
.
getMethod0
(
name
,
parameterTypes
))
!=
null
)
{
return
res
;
...
...
@@ -2695,9 +2695,9 @@ public final
}
}
// Search superinterfaces' methods
Class
[]
interfaces
=
getInterfaces
();
Class
<?>
[]
interfaces
=
getInterfaces
();
for
(
int
i
=
0
;
i
<
interfaces
.
length
;
i
++)
{
Class
c
=
interfaces
[
i
];
Class
<?>
c
=
interfaces
[
i
];
if
((
res
=
c
.
getMethod0
(
name
,
parameterTypes
))
!=
null
)
{
return
res
;
}
...
...
@@ -2706,7 +2706,7 @@ public final
return
null
;
}
private
Constructor
<
T
>
getConstructor0
(
Class
[]
parameterTypes
,
private
Constructor
<
T
>
getConstructor0
(
Class
<?>
[]
parameterTypes
,
int
which
)
throws
NoSuchMethodException
{
Constructor
<
T
>[]
constructors
=
privateGetDeclaredConstructors
((
which
==
Member
.
PUBLIC
));
...
...
@@ -2775,9 +2775,9 @@ public final
private
native
Field
[]
getDeclaredFields0
(
boolean
publicOnly
);
private
native
Method
[]
getDeclaredMethods0
(
boolean
publicOnly
);
private
native
Constructor
<
T
>[]
getDeclaredConstructors0
(
boolean
publicOnly
);
private
native
Class
[]
getDeclaredClasses0
();
private
native
Class
<?>
[]
getDeclaredClasses0
();
private
static
String
argumentTypesToString
(
Class
[]
argTypes
)
{
private
static
String
argumentTypesToString
(
Class
<?>
[]
argTypes
)
{
StringBuilder
buf
=
new
StringBuilder
();
buf
.
append
(
"("
);
if
(
argTypes
!=
null
)
{
...
...
@@ -2785,7 +2785,7 @@ public final
if
(
i
>
0
)
{
buf
.
append
(
", "
);
}
Class
c
=
argTypes
[
i
];
Class
<?>
c
=
argTypes
[
i
];
buf
.
append
((
c
==
null
)
?
"null"
:
c
.
getName
());
}
}
...
...
@@ -2858,7 +2858,7 @@ public final
}
// Retrieves the desired assertion status of this class from the VM
private
static
native
boolean
desiredAssertionStatus0
(
Class
clazz
);
private
static
native
boolean
desiredAssertionStatus0
(
Class
<?>
clazz
);
/**
* Returns true if and only if this class was declared as an enum in the
...
...
@@ -2979,7 +2979,7 @@ public final
getName
()
+
" is not an enum type"
);
Map
<
String
,
T
>
m
=
new
HashMap
<
String
,
T
>(
2
*
universe
.
length
);
for
(
T
constant
:
universe
)
m
.
put
(((
Enum
)
constant
).
name
(),
constant
);
m
.
put
(((
Enum
<?>
)
constant
).
name
(),
constant
);
enumConstantDirectory
=
m
;
}
return
enumConstantDirectory
;
...
...
@@ -3077,8 +3077,8 @@ public final
}
// Annotations cache
private
transient
Map
<
Class
,
Annotation
>
annotations
;
private
transient
Map
<
Class
,
Annotation
>
declaredAnnotations
;
private
transient
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
annotations
;
private
transient
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
declaredAnnotations
;
private
synchronized
void
initAnnotationsIfNecessary
()
{
clearCachesOnClassRedefinition
();
...
...
@@ -3090,10 +3090,10 @@ public final
if
(
superClass
==
null
)
{
annotations
=
declaredAnnotations
;
}
else
{
annotations
=
new
HashMap
<
Class
,
Annotation
>();
annotations
=
new
HashMap
<
Class
<?
extends
Annotation
>
,
Annotation
>();
superClass
.
initAnnotationsIfNecessary
();
for
(
Map
.
Entry
<
Class
,
Annotation
>
e
:
superClass
.
annotations
.
entrySet
())
{
Class
annotationClass
=
e
.
getKey
();
for
(
Map
.
Entry
<
Class
<?
extends
Annotation
>
,
Annotation
>
e
:
superClass
.
annotations
.
entrySet
())
{
Class
<?
extends
Annotation
>
annotationClass
=
e
.
getKey
();
if
(
AnnotationType
.
getInstance
(
annotationClass
).
isInherited
())
annotations
.
put
(
annotationClass
,
e
.
getValue
());
}
...
...
src/share/classes/java/lang/Package.java
浏览文件 @
8ab4b652
...
...
@@ -320,7 +320,7 @@ public class Package implements java.lang.reflect.AnnotatedElement {
* @param class the class to get the package of.
* @return the package of the class. It may be null if no package
* information is available from the archive or codebase. */
static
Package
getPackage
(
Class
c
)
{
static
Package
getPackage
(
Class
<?>
c
)
{
String
name
=
c
.
getName
();
int
i
=
name
.
lastIndexOf
(
'.'
);
if
(
i
!=
-
1
)
{
...
...
src/share/classes/java/lang/reflect/AccessibleObject.java
浏览文件 @
8ab4b652
...
...
@@ -131,7 +131,7 @@ public class AccessibleObject implements AnnotatedElement {
throws
SecurityException
{
if
(
obj
instanceof
Constructor
&&
flag
==
true
)
{
Constructor
c
=
(
Constructor
)
obj
;
Constructor
<?>
c
=
(
Constructor
<?>
)
obj
;
if
(
c
.
getDeclaringClass
()
==
Class
.
class
)
{
throw
new
SecurityException
(
"Can not make a java.lang.Class"
+
" constructor accessible"
);
...
...
src/share/classes/java/lang/reflect/Constructor.java
浏览文件 @
8ab4b652
...
...
@@ -64,8 +64,8 @@ public final
private
Class
<
T
>
clazz
;
private
int
slot
;
private
Class
[]
parameterTypes
;
private
Class
[]
exceptionTypes
;
private
Class
<?>[]
parameterTypes
;
private
Class
<?>[]
exceptionTypes
;
private
int
modifiers
;
// Generics and annotations support
private
transient
String
signature
;
...
...
@@ -80,7 +80,7 @@ public final
// always succeed (it is not affected by the granting or revoking
// of permissions); we speed up the check in the common case by
// remembering the last Class for which the check succeeded.
private
volatile
Class
securityCheckCache
;
private
volatile
Class
<?>
securityCheckCache
;
// Generics infrastructure
// Accessor for factory
...
...
@@ -113,8 +113,8 @@ public final
* package via sun.reflect.LangReflectAccess.
*/
Constructor
(
Class
<
T
>
declaringClass
,
Class
[]
parameterTypes
,
Class
[]
checkedExceptions
,
Class
<?>
[]
parameterTypes
,
Class
<?>
[]
checkedExceptions
,
int
modifiers
,
int
slot
,
String
signature
,
...
...
@@ -307,11 +307,11 @@ public final
*/
public
boolean
equals
(
Object
obj
)
{
if
(
obj
!=
null
&&
obj
instanceof
Constructor
)
{
Constructor
other
=
(
Constructor
)
obj
;
Constructor
<?>
other
=
(
Constructor
<?>
)
obj
;
if
(
getDeclaringClass
()
==
other
.
getDeclaringClass
())
{
/* Avoid unnecessary cloning */
Class
[]
params1
=
parameterTypes
;
Class
[]
params2
=
other
.
parameterTypes
;
Class
<?>
[]
params1
=
parameterTypes
;
Class
<?>
[]
params2
=
other
.
parameterTypes
;
if
(
params1
.
length
==
params2
.
length
)
{
for
(
int
i
=
0
;
i
<
params1
.
length
;
i
++)
{
if
(
params1
[
i
]
!=
params2
[
i
])
...
...
@@ -357,14 +357,14 @@ public final
}
sb
.
append
(
Field
.
getTypeName
(
getDeclaringClass
()));
sb
.
append
(
"("
);
Class
[]
params
=
parameterTypes
;
// avoid clone
Class
<?>
[]
params
=
parameterTypes
;
// avoid clone
for
(
int
j
=
0
;
j
<
params
.
length
;
j
++)
{
sb
.
append
(
Field
.
getTypeName
(
params
[
j
]));
if
(
j
<
(
params
.
length
-
1
))
sb
.
append
(
","
);
}
sb
.
append
(
")"
);
Class
[]
exceptions
=
exceptionTypes
;
// avoid clone
Class
<?>
[]
exceptions
=
exceptionTypes
;
// avoid clone
if
(
exceptions
.
length
>
0
)
{
sb
.
append
(
" throws "
);
for
(
int
k
=
0
;
k
<
exceptions
.
length
;
k
++)
{
...
...
@@ -452,7 +452,7 @@ public final
sb
.
append
(
" throws "
);
for
(
int
k
=
0
;
k
<
exceptions
.
length
;
k
++)
{
sb
.
append
((
exceptions
[
k
]
instanceof
Class
)?
((
Class
)
exceptions
[
k
]).
getName
():
((
Class
<?>
)
exceptions
[
k
]).
getName
():
exceptions
[
k
].
toString
());
if
(
k
<
(
exceptions
.
length
-
1
))
sb
.
append
(
","
);
...
...
@@ -518,7 +518,7 @@ public final
{
if
(!
override
)
{
if
(!
Reflection
.
quickCheckMemberAccess
(
clazz
,
modifiers
))
{
Class
caller
=
Reflection
.
getCallerClass
(
2
);
Class
<?>
caller
=
Reflection
.
getCallerClass
(
2
);
if
(
securityCheckCache
!=
caller
)
{
Reflection
.
ensureMemberAccess
(
caller
,
clazz
,
null
,
modifiers
);
securityCheckCache
=
caller
;
...
...
@@ -625,9 +625,9 @@ public final
return
AnnotationParser
.
toArray
(
declaredAnnotations
());
}
private
transient
Map
<
Class
,
Annotation
>
declaredAnnotations
;
private
transient
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
declaredAnnotations
;
private
synchronized
Map
<
Class
,
Annotation
>
declaredAnnotations
()
{
private
synchronized
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
declaredAnnotations
()
{
if
(
declaredAnnotations
==
null
)
{
declaredAnnotations
=
AnnotationParser
.
parseAnnotations
(
annotations
,
sun
.
misc
.
SharedSecrets
.
getJavaLangAccess
().
...
...
src/share/classes/java/lang/reflect/Field.java
浏览文件 @
8ab4b652
...
...
@@ -58,12 +58,12 @@ import sun.reflect.annotation.AnnotationParser;
public
final
class
Field
extends
AccessibleObject
implements
Member
{
private
Class
clazz
;
private
Class
<?>
clazz
;
private
int
slot
;
// This is guaranteed to be interned by the VM in the 1.4
// reflection implementation
private
String
name
;
private
Class
type
;
private
Class
<?>
type
;
private
int
modifiers
;
// Generics and annotations support
private
transient
String
signature
;
...
...
@@ -81,8 +81,8 @@ class Field extends AccessibleObject implements Member {
// More complicated security check cache needed here than for
// Class.newInstance() and Constructor.newInstance()
private
Class
securityCheckCache
;
private
Class
securityCheckTargetClassCache
;
private
Class
<?>
securityCheckCache
;
private
Class
<?>
securityCheckTargetClassCache
;
// Generics infrastructure
...
...
@@ -112,9 +112,9 @@ class Field extends AccessibleObject implements Member {
* instantiation of these objects in Java code from the java.lang
* package via sun.reflect.LangReflectAccess.
*/
Field
(
Class
declaringClass
,
Field
(
Class
<?>
declaringClass
,
String
name
,
Class
type
,
Class
<?>
type
,
int
modifiers
,
int
slot
,
String
signature
,
...
...
@@ -964,10 +964,10 @@ class Field extends AccessibleObject implements Member {
private
void
doSecurityCheck
(
Object
obj
)
throws
IllegalAccessException
{
if
(!
override
)
{
if
(!
Reflection
.
quickCheckMemberAccess
(
clazz
,
modifiers
))
{
Class
caller
=
Reflection
.
getCallerClass
(
4
);
Class
targetClass
=
((
obj
==
null
||
!
Modifier
.
isProtected
(
modifiers
))
?
clazz
:
obj
.
getClass
());
Class
<?>
caller
=
Reflection
.
getCallerClass
(
4
);
Class
<?>
targetClass
=
((
obj
==
null
||
!
Modifier
.
isProtected
(
modifiers
))
?
clazz
:
obj
.
getClass
());
synchronized
(
this
)
{
if
((
securityCheckCache
==
caller
)
...
...
@@ -987,10 +987,10 @@ class Field extends AccessibleObject implements Member {
/*
* Utility routine to paper over array type names
*/
static
String
getTypeName
(
Class
type
)
{
static
String
getTypeName
(
Class
<?>
type
)
{
if
(
type
.
isArray
())
{
try
{
Class
cl
=
type
;
Class
<?>
cl
=
type
;
int
dimensions
=
0
;
while
(
cl
.
isArray
())
{
dimensions
++;
...
...
@@ -1025,9 +1025,9 @@ class Field extends AccessibleObject implements Member {
return
AnnotationParser
.
toArray
(
declaredAnnotations
());
}
private
transient
Map
<
Class
,
Annotation
>
declaredAnnotations
;
private
transient
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
declaredAnnotations
;
private
synchronized
Map
<
Class
,
Annotation
>
declaredAnnotations
()
{
private
synchronized
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
declaredAnnotations
()
{
if
(
declaredAnnotations
==
null
)
{
declaredAnnotations
=
AnnotationParser
.
parseAnnotations
(
annotations
,
sun
.
misc
.
SharedSecrets
.
getJavaLangAccess
().
...
...
src/share/classes/java/lang/reflect/Method.java
浏览文件 @
8ab4b652
...
...
@@ -61,14 +61,14 @@ import java.util.Map;
public
final
class
Method
extends
AccessibleObject
implements
GenericDeclaration
,
Member
{
private
Class
clazz
;
private
Class
<?>
clazz
;
private
int
slot
;
// This is guaranteed to be interned by the VM in the 1.4
// reflection implementation
private
String
name
;
private
Class
returnType
;
private
Class
[]
parameterTypes
;
private
Class
[]
exceptionTypes
;
private
Class
<?>
returnType
;
private
Class
<?>[]
parameterTypes
;
private
Class
<?>[]
exceptionTypes
;
private
int
modifiers
;
// Generics and annotations support
private
transient
String
signature
;
...
...
@@ -85,8 +85,8 @@ public final
// More complicated security check cache needed here than for
// Class.newInstance() and Constructor.newInstance()
private
Class
securityCheckCache
;
private
Class
securityCheckTargetClassCache
;
private
Class
<?>
securityCheckCache
;
private
Class
<?>
securityCheckTargetClassCache
;
// Generics infrastructure
...
...
@@ -114,11 +114,11 @@ public final
* instantiation of these objects in Java code from the java.lang
* package via sun.reflect.LangReflectAccess.
*/
Method
(
Class
declaringClass
,
Method
(
Class
<?>
declaringClass
,
String
name
,
Class
[]
parameterTypes
,
Class
returnType
,
Class
[]
checkedExceptions
,
Class
<?>
[]
parameterTypes
,
Class
<?>
returnType
,
Class
<?>
[]
checkedExceptions
,
int
modifiers
,
int
slot
,
String
signature
,
...
...
@@ -355,8 +355,8 @@ public final
if
(!
returnType
.
equals
(
other
.
getReturnType
()))
return
false
;
/* Avoid unnecessary cloning */
Class
[]
params1
=
parameterTypes
;
Class
[]
params2
=
other
.
parameterTypes
;
Class
<?>
[]
params1
=
parameterTypes
;
Class
<?>
[]
params2
=
other
.
parameterTypes
;
if
(
params1
.
length
==
params2
.
length
)
{
for
(
int
i
=
0
;
i
<
params1
.
length
;
i
++)
{
if
(
params1
[
i
]
!=
params2
[
i
])
...
...
@@ -410,14 +410,14 @@ public final
sb
.
append
(
Field
.
getTypeName
(
getReturnType
())
+
" "
);
sb
.
append
(
Field
.
getTypeName
(
getDeclaringClass
())
+
"."
);
sb
.
append
(
getName
()
+
"("
);
Class
[]
params
=
parameterTypes
;
// avoid clone
Class
<?>
[]
params
=
parameterTypes
;
// avoid clone
for
(
int
j
=
0
;
j
<
params
.
length
;
j
++)
{
sb
.
append
(
Field
.
getTypeName
(
params
[
j
]));
if
(
j
<
(
params
.
length
-
1
))
sb
.
append
(
","
);
}
sb
.
append
(
")"
);
Class
[]
exceptions
=
exceptionTypes
;
// avoid clone
Class
<?>
[]
exceptions
=
exceptionTypes
;
// avoid clone
if
(
exceptions
.
length
>
0
)
{
sb
.
append
(
" throws "
);
for
(
int
k
=
0
;
k
<
exceptions
.
length
;
k
++)
{
...
...
@@ -590,10 +590,10 @@ public final
{
if
(!
override
)
{
if
(!
Reflection
.
quickCheckMemberAccess
(
clazz
,
modifiers
))
{
Class
caller
=
Reflection
.
getCallerClass
(
1
);
Class
targetClass
=
((
obj
==
null
||
!
Modifier
.
isProtected
(
modifiers
))
?
clazz
:
obj
.
getClass
());
Class
<?>
caller
=
Reflection
.
getCallerClass
(
1
);
Class
<?>
targetClass
=
((
obj
==
null
||
!
Modifier
.
isProtected
(
modifiers
))
?
clazz
:
obj
.
getClass
());
boolean
cached
;
synchronized
(
this
)
{
...
...
@@ -702,9 +702,9 @@ public final
return
AnnotationParser
.
toArray
(
declaredAnnotations
());
}
private
transient
Map
<
Class
,
Annotation
>
declaredAnnotations
;
private
transient
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
declaredAnnotations
;
private
synchronized
Map
<
Class
,
Annotation
>
declaredAnnotations
()
{
private
synchronized
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
declaredAnnotations
()
{
if
(
declaredAnnotations
==
null
)
{
declaredAnnotations
=
AnnotationParser
.
parseAnnotations
(
annotations
,
sun
.
misc
.
SharedSecrets
.
getJavaLangAccess
().
...
...
@@ -731,7 +731,7 @@ public final
public
Object
getDefaultValue
()
{
if
(
annotationDefault
==
null
)
return
null
;
Class
memberType
=
AnnotationType
.
invocationHandlerReturnType
(
Class
<?>
memberType
=
AnnotationType
.
invocationHandlerReturnType
(
getReturnType
());
Object
result
=
AnnotationParser
.
parseMemberValue
(
memberType
,
ByteBuffer
.
wrap
(
annotationDefault
),
...
...
src/share/classes/java/lang/reflect/Proxy.java
浏览文件 @
8ab4b652
...
...
@@ -350,7 +350,7 @@ public class Proxy implements java.io.Serializable {
throw
new
IllegalArgumentException
(
"interface limit exceeded"
);
}
Class
proxyClass
=
null
;
Class
<?>
proxyClass
=
null
;
/* collect interface names to use as key for proxy class cache */
String
[]
interfaceNames
=
new
String
[
interfaces
.
length
];
...
...
@@ -364,7 +364,7 @@ public class Proxy implements java.io.Serializable {
* interface to the same Class object.
*/
String
interfaceName
=
interfaces
[
i
].
getName
();
Class
interfaceClass
=
null
;
Class
<?>
interfaceClass
=
null
;
try
{
interfaceClass
=
Class
.
forName
(
interfaceName
,
false
,
loader
);
}
catch
(
ClassNotFoundException
e
)
{
...
...
src/share/classes/java/lang/reflect/ReflectAccess.java
浏览文件 @
8ab4b652
...
...
@@ -33,9 +33,9 @@ import sun.reflect.ConstructorAccessor;
package to instantiate objects in this package. */
class
ReflectAccess
implements
sun
.
reflect
.
LangReflectAccess
{
public
Field
newField
(
Class
declaringClass
,
public
Field
newField
(
Class
<?>
declaringClass
,
String
name
,
Class
type
,
Class
<?>
type
,
int
modifiers
,
int
slot
,
String
signature
,
...
...
@@ -50,11 +50,11 @@ class ReflectAccess implements sun.reflect.LangReflectAccess {
annotations
);
}
public
Method
newMethod
(
Class
declaringClass
,
public
Method
newMethod
(
Class
<?>
declaringClass
,
String
name
,
Class
[]
parameterTypes
,
Class
returnType
,
Class
[]
checkedExceptions
,
Class
<?>
[]
parameterTypes
,
Class
<?>
returnType
,
Class
<?>
[]
checkedExceptions
,
int
modifiers
,
int
slot
,
String
signature
,
...
...
@@ -76,8 +76,8 @@ class ReflectAccess implements sun.reflect.LangReflectAccess {
}
public
<
T
>
Constructor
<
T
>
newConstructor
(
Class
<
T
>
declaringClass
,
Class
[]
parameterTypes
,
Class
[]
checkedExceptions
,
Class
<?>
[]
parameterTypes
,
Class
<?>
[]
checkedExceptions
,
int
modifiers
,
int
slot
,
String
signature
,
...
...
@@ -102,29 +102,29 @@ class ReflectAccess implements sun.reflect.LangReflectAccess {
m
.
setMethodAccessor
(
accessor
);
}
public
ConstructorAccessor
getConstructorAccessor
(
Constructor
c
)
{
public
ConstructorAccessor
getConstructorAccessor
(
Constructor
<?>
c
)
{
return
c
.
getConstructorAccessor
();
}
public
void
setConstructorAccessor
(
Constructor
c
,
public
void
setConstructorAccessor
(
Constructor
<?>
c
,
ConstructorAccessor
accessor
)
{
c
.
setConstructorAccessor
(
accessor
);
}
public
int
getConstructorSlot
(
Constructor
c
)
{
public
int
getConstructorSlot
(
Constructor
<?>
c
)
{
return
c
.
getSlot
();
}
public
String
getConstructorSignature
(
Constructor
c
)
{
public
String
getConstructorSignature
(
Constructor
<?>
c
)
{
return
c
.
getSignature
();
}
public
byte
[]
getConstructorAnnotations
(
Constructor
c
)
{
public
byte
[]
getConstructorAnnotations
(
Constructor
<?>
c
)
{
return
c
.
getRawAnnotations
();
}
public
byte
[]
getConstructorParameterAnnotations
(
Constructor
c
)
{
public
byte
[]
getConstructorParameterAnnotations
(
Constructor
<?>
c
)
{
return
c
.
getRawParameterAnnotations
();
}
...
...
src/share/classes/sun/reflect/LangReflectAccess.java
浏览文件 @
8ab4b652
...
...
@@ -33,9 +33,9 @@ import java.lang.reflect.*;
public
interface
LangReflectAccess
{
/** Creates a new java.lang.reflect.Field. Access checks as per
java.lang.reflect.AccessibleObject are not overridden. */
public
Field
newField
(
Class
declaringClass
,
public
Field
newField
(
Class
<?>
declaringClass
,
String
name
,
Class
type
,
Class
<?>
type
,
int
modifiers
,
int
slot
,
String
signature
,
...
...
@@ -43,11 +43,11 @@ public interface LangReflectAccess {
/** Creates a new java.lang.reflect.Method. Access checks as per
java.lang.reflect.AccessibleObject are not overridden. */
public
Method
newMethod
(
Class
declaringClass
,
public
Method
newMethod
(
Class
<?>
declaringClass
,
String
name
,
Class
[]
parameterTypes
,
Class
returnType
,
Class
[]
checkedExceptions
,
Class
<?>
[]
parameterTypes
,
Class
<?>
returnType
,
Class
<?>
[]
checkedExceptions
,
int
modifiers
,
int
slot
,
String
signature
,
...
...
@@ -58,8 +58,8 @@ public interface LangReflectAccess {
/** Creates a new java.lang.reflect.Constructor. Access checks as
per java.lang.reflect.AccessibleObject are not overridden. */
public
<
T
>
Constructor
<
T
>
newConstructor
(
Class
<
T
>
declaringClass
,
Class
[]
parameterTypes
,
Class
[]
checkedExceptions
,
Class
<?>
[]
parameterTypes
,
Class
<?>
[]
checkedExceptions
,
int
modifiers
,
int
slot
,
String
signature
,
...
...
@@ -74,24 +74,24 @@ public interface LangReflectAccess {
/** Gets the ConstructorAccessor object for a
java.lang.reflect.Constructor */
public
ConstructorAccessor
getConstructorAccessor
(
Constructor
c
);
public
ConstructorAccessor
getConstructorAccessor
(
Constructor
<?>
c
);
/** Sets the ConstructorAccessor object for a
java.lang.reflect.Constructor */
public
void
setConstructorAccessor
(
Constructor
c
,
public
void
setConstructorAccessor
(
Constructor
<?>
c
,
ConstructorAccessor
accessor
);
/** Gets the "slot" field from a Constructor (used for serialization) */
public
int
getConstructorSlot
(
Constructor
c
);
public
int
getConstructorSlot
(
Constructor
<?>
c
);
/** Gets the "signature" field from a Constructor (used for serialization) */
public
String
getConstructorSignature
(
Constructor
c
);
public
String
getConstructorSignature
(
Constructor
<?>
c
);
/** Gets the "annotations" field from a Constructor (used for serialization) */
public
byte
[]
getConstructorAnnotations
(
Constructor
c
);
public
byte
[]
getConstructorAnnotations
(
Constructor
<?>
c
);
/** Gets the "parameterAnnotations" field from a Constructor (used for serialization) */
public
byte
[]
getConstructorParameterAnnotations
(
Constructor
c
);
public
byte
[]
getConstructorParameterAnnotations
(
Constructor
<?>
c
);
//
// Copying routines, needed to quickly fabricate new Field,
...
...
src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
浏览文件 @
8ab4b652
...
...
@@ -40,17 +40,17 @@ import java.security.PrivilegedAction;
* @since 1.5
*/
class
AnnotationInvocationHandler
implements
InvocationHandler
,
Serializable
{
private
final
Class
type
;
private
final
Class
<?
extends
Annotation
>
type
;
private
final
Map
<
String
,
Object
>
memberValues
;
AnnotationInvocationHandler
(
Class
type
,
Map
<
String
,
Object
>
memberValues
)
{
AnnotationInvocationHandler
(
Class
<?
extends
Annotation
>
type
,
Map
<
String
,
Object
>
memberValues
)
{
this
.
type
=
type
;
this
.
memberValues
=
memberValues
;
}
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
{
String
member
=
method
.
getName
();
Class
[]
paramTypes
=
method
.
getParameterTypes
();
Class
<?>
[]
paramTypes
=
method
.
getParameterTypes
();
// Handle Object and Annotation methods
if
(
member
.
equals
(
"equals"
)
&&
paramTypes
.
length
==
1
&&
...
...
@@ -84,7 +84,7 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
* if Cloneable had a public clone method.
*/
private
Object
cloneArray
(
Object
array
)
{
Class
type
=
array
.
getClass
();
Class
<?>
type
=
array
.
getClass
();
if
(
type
==
byte
[].
class
)
{
byte
[]
byteArray
=
(
byte
[])
array
;
...
...
@@ -151,7 +151,7 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
* Translates a member value (in "dynamic proxy return form") into a string
*/
private
static
String
memberValueToString
(
Object
value
)
{
Class
type
=
value
.
getClass
();
Class
<?>
type
=
value
.
getClass
();
if
(!
type
.
isArray
())
// primitive, string, class, enum const,
// or annotation
return
value
.
toString
();
...
...
@@ -229,7 +229,7 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
* two members are identical object references.
*/
private
static
boolean
memberValueEquals
(
Object
v1
,
Object
v2
)
{
Class
type
=
v1
.
getClass
();
Class
<?>
type
=
v1
.
getClass
();
// Check for primitive, string, class, enum const, annotation,
// or ExceptionProxy
...
...
@@ -301,7 +301,7 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
* Computes hashCode of a member value (in "dynamic proxy return form")
*/
private
static
int
memberValueHashCode
(
Object
value
)
{
Class
type
=
value
.
getClass
();
Class
<?>
type
=
value
.
getClass
();
if
(!
type
.
isArray
())
// primitive, string, class, enum const,
// or annotation
return
value
.
hashCode
();
...
...
@@ -340,11 +340,11 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
return
;
}
Map
<
String
,
Class
>
memberTypes
=
annotationType
.
memberTypes
();
Map
<
String
,
Class
<?>
>
memberTypes
=
annotationType
.
memberTypes
();
for
(
Map
.
Entry
<
String
,
Object
>
memberValue
:
memberValues
.
entrySet
())
{
String
name
=
memberValue
.
getKey
();
Class
memberType
=
memberTypes
.
get
(
name
);
Class
<?>
memberType
=
memberTypes
.
get
(
name
);
if
(
memberType
!=
null
)
{
// i.e. member still exists
Object
value
=
memberValue
.
getValue
();
if
(!(
memberType
.
isInstance
(
value
)
||
...
...
src/share/classes/sun/reflect/annotation/AnnotationParser.java
浏览文件 @
8ab4b652
...
...
@@ -59,10 +59,10 @@ public class AnnotationParser {
* @throws AnnotationFormatError if an annotation is found to be
* malformed.
*/
public
static
Map
<
Class
,
Annotation
>
parseAnnotations
(
public
static
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
parseAnnotations
(
byte
[]
rawAnnotations
,
ConstantPool
constPool
,
Class
container
)
{
Class
<?>
container
)
{
if
(
rawAnnotations
==
null
)
return
Collections
.
emptyMap
();
...
...
@@ -76,17 +76,18 @@ public class AnnotationParser {
}
}
private
static
Map
<
Class
,
Annotation
>
parseAnnotations2
(
private
static
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
parseAnnotations2
(
byte
[]
rawAnnotations
,
ConstantPool
constPool
,
Class
container
)
{
Map
<
Class
,
Annotation
>
result
=
new
LinkedHashMap
<
Class
,
Annotation
>();
Class
<?>
container
)
{
Map
<
Class
<?
extends
Annotation
>,
Annotation
>
result
=
new
LinkedHashMap
<
Class
<?
extends
Annotation
>,
Annotation
>();
ByteBuffer
buf
=
ByteBuffer
.
wrap
(
rawAnnotations
);
int
numAnnotations
=
buf
.
getShort
()
&
0xFFFF
;
for
(
int
i
=
0
;
i
<
numAnnotations
;
i
++)
{
Annotation
a
=
parseAnnotation
(
buf
,
constPool
,
container
,
false
);
if
(
a
!=
null
)
{
Class
klass
=
a
.
annotationType
();
Class
<?
extends
Annotation
>
klass
=
a
.
annotationType
();
AnnotationType
type
=
AnnotationType
.
getInstance
(
klass
);
if
(
type
.
retention
()
==
RetentionPolicy
.
RUNTIME
)
if
(
result
.
put
(
klass
,
a
)
!=
null
)
...
...
@@ -123,7 +124,7 @@ public class AnnotationParser {
public
static
Annotation
[][]
parseParameterAnnotations
(
byte
[]
rawAnnotations
,
ConstantPool
constPool
,
Class
container
)
{
Class
<?>
container
)
{
try
{
return
parseParameterAnnotations2
(
rawAnnotations
,
constPool
,
container
);
}
catch
(
BufferUnderflowException
e
)
{
...
...
@@ -138,7 +139,7 @@ public class AnnotationParser {
private
static
Annotation
[][]
parseParameterAnnotations2
(
byte
[]
rawAnnotations
,
ConstantPool
constPool
,
Class
container
)
{
Class
<?>
container
)
{
ByteBuffer
buf
=
ByteBuffer
.
wrap
(
rawAnnotations
);
int
numParameters
=
buf
.
get
()
&
0xFF
;
Annotation
[][]
result
=
new
Annotation
[
numParameters
][];
...
...
@@ -188,15 +189,15 @@ public class AnnotationParser {
*/
private
static
Annotation
parseAnnotation
(
ByteBuffer
buf
,
ConstantPool
constPool
,
Class
container
,
Class
<?>
container
,
boolean
exceptionOnMissingAnnotationClass
)
{
int
typeIndex
=
buf
.
getShort
()
&
0xFFFF
;
Class
annotationClass
=
null
;
Class
<?
extends
Annotation
>
annotationClass
=
null
;
String
sig
=
"[unknown]"
;
try
{
try
{
sig
=
constPool
.
getUTF8At
(
typeIndex
);
annotationClass
=
parseSig
(
sig
,
container
);
annotationClass
=
(
Class
<?
extends
Annotation
>)
parseSig
(
sig
,
container
);
}
catch
(
IllegalArgumentException
ex
)
{
// support obsolete early jsr175 format class files
annotationClass
=
constPool
.
getClassAt
(
typeIndex
);
...
...
@@ -223,7 +224,7 @@ public class AnnotationParser {
return
null
;
}
Map
<
String
,
Class
>
memberTypes
=
type
.
memberTypes
();
Map
<
String
,
Class
<?>
>
memberTypes
=
type
.
memberTypes
();
Map
<
String
,
Object
>
memberValues
=
new
LinkedHashMap
<
String
,
Object
>(
type
.
memberDefaults
());
...
...
@@ -231,7 +232,7 @@ public class AnnotationParser {
for
(
int
i
=
0
;
i
<
numMembers
;
i
++)
{
int
memberNameIndex
=
buf
.
getShort
()
&
0xFFFF
;
String
memberName
=
constPool
.
getUTF8At
(
memberNameIndex
);
Class
memberType
=
memberTypes
.
get
(
memberName
);
Class
<?>
memberType
=
memberTypes
.
get
(
memberName
);
if
(
memberType
==
null
)
{
// Member is no longer present in annotation type; ignore it
...
...
@@ -252,7 +253,7 @@ public class AnnotationParser {
* member -> value map.
*/
public
static
Annotation
annotationForMap
(
Class
type
,
Map
<
String
,
Object
>
memberValues
)
Class
<?
extends
Annotation
>
type
,
Map
<
String
,
Object
>
memberValues
)
{
return
(
Annotation
)
Proxy
.
newProxyInstance
(
type
.
getClassLoader
(),
new
Class
[]
{
type
},
...
...
@@ -286,14 +287,15 @@ public class AnnotationParser {
* The member must be of the indicated type. If it is not, this
* method returns an AnnotationTypeMismatchExceptionProxy.
*/
public
static
Object
parseMemberValue
(
Class
memberType
,
ByteBuffer
buf
,
public
static
Object
parseMemberValue
(
Class
<?>
memberType
,
ByteBuffer
buf
,
ConstantPool
constPool
,
Class
container
)
{
Class
<?>
container
)
{
Object
result
=
null
;
int
tag
=
buf
.
get
();
switch
(
tag
)
{
case
'e'
:
return
parseEnumValue
(
memberType
,
buf
,
constPool
,
container
);
return
parseEnumValue
(
(
Class
<?
extends
Enum
<?>>)
memberType
,
buf
,
constPool
,
container
);
case
'c'
:
result
=
parseClassValue
(
buf
,
constPool
,
container
);
break
;
...
...
@@ -361,7 +363,7 @@ public class AnnotationParser {
*/
private
static
Object
parseClassValue
(
ByteBuffer
buf
,
ConstantPool
constPool
,
Class
container
)
{
Class
<?>
container
)
{
int
classIndex
=
buf
.
getShort
()
&
0xFFFF
;
try
{
try
{
...
...
@@ -379,7 +381,7 @@ public class AnnotationParser {
}
}
private
static
Class
<?>
parseSig
(
String
sig
,
Class
container
)
{
private
static
Class
<?>
parseSig
(
String
sig
,
Class
<?>
container
)
{
if
(
sig
.
equals
(
"V"
))
return
void
.
class
;
SignatureParser
parser
=
SignatureParser
.
make
();
TypeSignature
typeSig
=
parser
.
parseTypeSig
(
sig
);
...
...
@@ -389,7 +391,7 @@ public class AnnotationParser {
Type
result
=
reify
.
getResult
();
return
toClass
(
result
);
}
static
Class
toClass
(
Type
o
)
{
static
Class
<?>
toClass
(
Type
o
)
{
if
(
o
instanceof
GenericArrayType
)
return
Array
.
newInstance
(
toClass
(((
GenericArrayType
)
o
).
getGenericComponentType
()),
0
)
...
...
@@ -409,9 +411,9 @@ public class AnnotationParser {
* u2 const_name_index;
* } enum_const_value;
*/
private
static
Object
parseEnumValue
(
Class
enumType
,
ByteBuffer
buf
,
private
static
Object
parseEnumValue
(
Class
<?
extends
Enum
>
enumType
,
ByteBuffer
buf
,
ConstantPool
constPool
,
Class
container
)
{
Class
<?>
container
)
{
int
typeNameIndex
=
buf
.
getShort
()
&
0xFFFF
;
String
typeName
=
constPool
.
getUTF8At
(
typeNameIndex
);
int
constNameIndex
=
buf
.
getShort
()
&
0xFFFF
;
...
...
@@ -449,12 +451,12 @@ public class AnnotationParser {
* If the array values do not match arrayType, an
* AnnotationTypeMismatchExceptionProxy will be returned.
*/
private
static
Object
parseArray
(
Class
arrayType
,
private
static
Object
parseArray
(
Class
<?>
arrayType
,
ByteBuffer
buf
,
ConstantPool
constPool
,
Class
container
)
{
Class
<?>
container
)
{
int
length
=
buf
.
getShort
()
&
0xFFFF
;
// Number of array components
Class
componentType
=
arrayType
.
getComponentType
();
Class
<?>
componentType
=
arrayType
.
getComponentType
();
if
(
componentType
==
byte
.
class
)
{
return
parseByteArray
(
length
,
buf
,
constPool
);
...
...
@@ -477,11 +479,11 @@ public class AnnotationParser {
}
else
if
(
componentType
==
Class
.
class
)
{
return
parseClassArray
(
length
,
buf
,
constPool
,
container
);
}
else
if
(
componentType
.
isEnum
())
{
return
parseEnumArray
(
length
,
componentType
,
buf
,
return
parseEnumArray
(
length
,
(
Class
<?
extends
Enum
>)
componentType
,
buf
,
constPool
,
container
);
}
else
{
assert
componentType
.
isAnnotation
();
return
parseAnnotationArray
(
length
,
componentType
,
buf
,
return
parseAnnotationArray
(
length
,
(
Class
<?
extends
Annotation
>)
componentType
,
buf
,
constPool
,
container
);
}
}
...
...
@@ -660,8 +662,8 @@ public class AnnotationParser {
private
static
Object
parseClassArray
(
int
length
,
ByteBuffer
buf
,
ConstantPool
constPool
,
Class
container
)
{
Object
[]
result
=
new
Class
[
length
];
Class
<?>
container
)
{
Object
[]
result
=
new
Class
<?>
[
length
];
boolean
typeMismatch
=
false
;
int
tag
=
0
;
...
...
@@ -677,10 +679,10 @@ public class AnnotationParser {
return
typeMismatch
?
exceptionProxy
(
tag
)
:
result
;
}
private
static
Object
parseEnumArray
(
int
length
,
Class
enumType
,
private
static
Object
parseEnumArray
(
int
length
,
Class
<?
extends
Enum
>
enumType
,
ByteBuffer
buf
,
ConstantPool
constPool
,
Class
container
)
{
Class
<?>
container
)
{
Object
[]
result
=
(
Object
[])
Array
.
newInstance
(
enumType
,
length
);
boolean
typeMismatch
=
false
;
int
tag
=
0
;
...
...
@@ -698,10 +700,10 @@ public class AnnotationParser {
}
private
static
Object
parseAnnotationArray
(
int
length
,
Class
annotationType
,
Class
<?
extends
Annotation
>
annotationType
,
ByteBuffer
buf
,
ConstantPool
constPool
,
Class
container
)
{
Class
<?>
container
)
{
Object
[]
result
=
(
Object
[])
Array
.
newInstance
(
annotationType
,
length
);
boolean
typeMismatch
=
false
;
int
tag
=
0
;
...
...
@@ -797,7 +799,7 @@ public class AnnotationParser {
* it is needed.
*/
private
static
final
Annotation
[]
EMPTY_ANNOTATION_ARRAY
=
new
Annotation
[
0
];
public
static
Annotation
[]
toArray
(
Map
<
Class
,
Annotation
>
annotations
)
{
public
static
Annotation
[]
toArray
(
Map
<
Class
<?
extends
Annotation
>
,
Annotation
>
annotations
)
{
return
annotations
.
values
().
toArray
(
EMPTY_ANNOTATION_ARRAY
);
}
}
src/share/classes/sun/reflect/annotation/AnnotationType.java
浏览文件 @
8ab4b652
...
...
@@ -45,7 +45,7 @@ public class AnnotationType {
* types. This matches the return value that must be used for a
* dynamic proxy, allowing for a simple isInstance test.
*/
private
final
Map
<
String
,
Class
>
memberTypes
=
new
HashMap
<
String
,
Class
>();
private
final
Map
<
String
,
Class
<?>>
memberTypes
=
new
HashMap
<
String
,
Class
<?>
>();
/**
* Member name -> default value mapping.
...
...
@@ -76,12 +76,12 @@ public class AnnotationType {
* does not represent a valid annotation type
*/
public
static
synchronized
AnnotationType
getInstance
(
Class
annotationClass
)
Class
<?
extends
Annotation
>
annotationClass
)
{
AnnotationType
result
=
sun
.
misc
.
SharedSecrets
.
getJavaLangAccess
().
getAnnotationType
(
annotationClass
);
if
(
result
==
null
)
result
=
new
AnnotationType
((
Class
<?>)
annotationClass
);
result
=
new
AnnotationType
((
Class
<?
extends
Annotation
>)
annotationClass
);
return
result
;
}
...
...
@@ -93,7 +93,7 @@ public class AnnotationType {
* @throw IllegalArgumentException if the specified class object for
* does not represent a valid annotation type
*/
private
AnnotationType
(
final
Class
<?>
annotationClass
)
{
private
AnnotationType
(
final
Class
<?
extends
Annotation
>
annotationClass
)
{
if
(!
annotationClass
.
isAnnotation
())
throw
new
IllegalArgumentException
(
"Not an annotation type"
);
...
...
@@ -110,7 +110,7 @@ public class AnnotationType {
if
(
method
.
getParameterTypes
().
length
!=
0
)
throw
new
IllegalArgumentException
(
method
+
" has params"
);
String
name
=
method
.
getName
();
Class
type
=
method
.
getReturnType
();
Class
<?>
type
=
method
.
getReturnType
();
memberTypes
.
put
(
name
,
invocationHandlerReturnType
(
type
));
members
.
put
(
name
,
method
);
...
...
@@ -140,7 +140,7 @@ public class AnnotationType {
* the specified type (which is assumed to be a legal member type
* for an annotation).
*/
public
static
Class
invocationHandlerReturnType
(
Class
type
)
{
public
static
Class
<?>
invocationHandlerReturnType
(
Class
<?>
type
)
{
// Translate primitives to wrappers
if
(
type
==
byte
.
class
)
return
Byte
.
class
;
...
...
@@ -167,7 +167,7 @@ public class AnnotationType {
* Returns member types for this annotation type
* (member name -> type mapping).
*/
public
Map
<
String
,
Class
>
memberTypes
()
{
public
Map
<
String
,
Class
<?>
>
memberTypes
()
{
return
memberTypes
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录