Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
fcc716d5
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看板
提交
fcc716d5
编写于
10月 11, 2013
作者:
J
jfranck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8023301: Enhance generic classes
Reviewed-by: mchung, hawtin
上级
bae14c82
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
1 deletion
+56
-1
src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java
.../reflect/generics/reflectiveObjects/TypeVariableImpl.java
+20
-1
src/share/classes/sun/reflect/misc/ReflectUtil.java
src/share/classes/sun/reflect/misc/ReflectUtil.java
+36
-0
未找到文件。
src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java
浏览文件 @
fcc716d5
...
...
@@ -28,7 +28,10 @@ package sun.reflect.generics.reflectiveObjects;
import
java.lang.annotation.*
;
import
java.lang.reflect.AnnotatedType
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.GenericDeclaration
;
import
java.lang.reflect.Member
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Type
;
import
java.lang.reflect.TypeVariable
;
import
java.util.LinkedHashMap
;
...
...
@@ -40,6 +43,7 @@ import sun.reflect.annotation.AnnotationType;
import
sun.reflect.generics.factory.GenericsFactory
;
import
sun.reflect.generics.tree.FieldTypeSignature
;
import
sun.reflect.generics.visitor.Reifier
;
import
sun.reflect.misc.ReflectUtil
;
/**
* Implementation of <tt>java.lang.reflect.TypeVariable</tt> interface
...
...
@@ -95,6 +99,13 @@ public class TypeVariableImpl<D extends GenericDeclaration>
TypeVariableImpl
<
T
>
make
(
T
decl
,
String
name
,
FieldTypeSignature
[]
bs
,
GenericsFactory
f
)
{
if
(!((
decl
instanceof
Class
)
||
(
decl
instanceof
Method
)
||
(
decl
instanceof
Constructor
)))
{
throw
new
AssertionError
(
"Unexpected kind of GenericDeclaration"
+
decl
.
getClass
().
toString
());
}
return
new
TypeVariableImpl
<
T
>(
decl
,
name
,
bs
,
f
);
}
...
...
@@ -149,6 +160,13 @@ public class TypeVariableImpl<D extends GenericDeclaration>
* @since 1.5
*/
public
D
getGenericDeclaration
(){
if
(
genericDeclaration
instanceof
Class
)
ReflectUtil
.
checkPackageAccess
((
Class
)
genericDeclaration
);
else
if
((
genericDeclaration
instanceof
Method
)
||
(
genericDeclaration
instanceof
Constructor
))
ReflectUtil
.
conservativeCheckMemberAccess
((
Member
)
genericDeclaration
);
else
throw
new
AssertionError
(
"Unexpected kind of GenericDeclaration"
);
return
genericDeclaration
;
}
...
...
@@ -164,7 +182,8 @@ public class TypeVariableImpl<D extends GenericDeclaration>
@Override
public
boolean
equals
(
Object
o
)
{
if
(
o
instanceof
TypeVariable
)
{
if
(
o
instanceof
TypeVariable
&&
o
.
getClass
()
==
TypeVariableImpl
.
class
)
{
TypeVariable
<?>
that
=
(
TypeVariable
<?>)
o
;
GenericDeclaration
thatDecl
=
that
.
getGenericDeclaration
();
...
...
src/share/classes/sun/reflect/misc/ReflectUtil.java
浏览文件 @
fcc716d5
...
...
@@ -26,11 +26,13 @@
package
sun.reflect.misc
;
import
java.lang.reflect.Member
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.lang.reflect.Proxy
;
import
java.util.Arrays
;
import
sun.reflect.Reflection
;
import
sun.security.util.SecurityConstants
;
public
final
class
ReflectUtil
{
...
...
@@ -117,6 +119,40 @@ public final class ReflectUtil {
return
false
;
}
/**
* Does a conservative approximation of member access check. Use this if
* you don't have an actual 'userland' caller Class/ClassLoader available.
* This might be more restrictive than a precise member access check where
* you have a caller, but should never allow a member access that is
* forbidden.
*
* @param m the {@code Member} about to be accessed
*/
public
static
void
conservativeCheckMemberAccess
(
Member
m
)
throws
SecurityException
{
final
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
==
null
)
return
;
// Check for package access on the declaring class.
//
// In addition, unless the member and the declaring class are both
// public check for access declared member permissions.
//
// This is done regardless of ClassLoader relations between the {@code
// Member m} and any potential caller.
final
Class
<?>
declaringClass
=
m
.
getDeclaringClass
();
checkPackageAccess
(
declaringClass
);
if
(
Modifier
.
isPublic
(
m
.
getModifiers
())
&&
Modifier
.
isPublic
(
declaringClass
.
getModifiers
()))
return
;
// Check for declared member access.
sm
.
checkPermission
(
SecurityConstants
.
CHECK_MEMBER_ACCESS_PERMISSION
);
}
/**
* Checks package access on the given class.
*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录