Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
bf839c04
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看板
提交
bf839c04
编写于
12月 13, 2017
作者:
I
igerasim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8193156: Need to backout fixes for JDK-8058547, JDK-8055753, JDK-8085903
Reviewed-by: mullan
上级
7d2c99ae
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
18 addition
and
128 deletion
+18
-128
src/share/classes/java/security/ProtectionDomain.java
src/share/classes/java/security/ProtectionDomain.java
+18
-128
未找到文件。
src/share/classes/java/security/ProtectionDomain.java
浏览文件 @
bf839c04
/*
* Copyright (c) 1997, 201
6
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
7
, 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
...
...
@@ -25,27 +25,21 @@
package
java.security
;
import
java.lang.ref.Reference
;
import
java.lang.ref.ReferenceQueue
;
import
java.lang.ref.SoftReference
;
import
java.lang.ref.WeakReference
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.WeakHashMap
;
import
sun.misc.JavaSecurityAccess
;
import
sun.misc.JavaSecurityProtectionDomainAccess
;
import
static
sun
.
misc
.
JavaSecurityProtectionDomainAccess
.
ProtectionDomainCache
;
import
sun.misc.SharedSecrets
;
import
sun.security.util.Debug
;
import
sun.security.util.SecurityConstants
;
import
sun.misc.JavaSecurityAccess
;
import
sun.misc.SharedSecrets
;
/**
*
*<p>
* This ProtectionDomain class encapsulates the characteristics of a domain,
* The ProtectionDomain class encapsulates the characteristics of a domain,
* which encloses a set of classes whose instances are granted a set
* of permissions when being executed on behalf of a given set of Principals.
* <p>
...
...
@@ -460,135 +454,31 @@ public class ProtectionDomain {
/**
* Used for storing ProtectionDomains as keys in a Map.
*/
static
final
class
Key
{}
final
class
Key
{}
static
{
SharedSecrets
.
setJavaSecurityProtectionDomainAccess
(
new
JavaSecurityProtectionDomainAccess
()
{
@Override
public
ProtectionDomainCache
getProtectionDomainCache
()
{
return
new
PDCache
();
}
@Override
public
boolean
getStaticPermissionsField
(
ProtectionDomain
pd
)
{
return
pd
.
staticPermissions
;
}
});
}
/**
* A cache of ProtectionDomains and their Permissions.
*
* This class stores ProtectionDomains as weak keys in a ConcurrentHashMap
* with additional support for checking and removing weak keys that are no
* longer in use. There can be cases where the permission collection may
* have a chain of strong references back to the ProtectionDomain, which
* ordinarily would prevent the entry from being removed from the map. To
* address that, we wrap the permission collection in a SoftReference so
* that it can be reclaimed by the garbage collector due to memory demand.
*/
private
static
class
PDCache
implements
ProtectionDomainCache
{
private
final
ConcurrentHashMap
<
WeakProtectionDomainKey
,
SoftReference
<
PermissionCollection
>>
pdMap
=
new
ConcurrentHashMap
<>();
private
final
ReferenceQueue
<
Key
>
queue
=
new
ReferenceQueue
<>();
@Override
public
void
put
(
ProtectionDomain
pd
,
PermissionCollection
pc
)
{
processQueue
(
queue
,
pdMap
);
WeakProtectionDomainKey
weakPd
=
new
WeakProtectionDomainKey
(
pd
,
queue
);
pdMap
.
put
(
weakPd
,
new
SoftReference
<>(
pc
));
return
new
ProtectionDomainCache
()
{
private
final
Map
<
Key
,
PermissionCollection
>
map
=
Collections
.
synchronizedMap
(
new
WeakHashMap
<
Key
,
PermissionCollection
>());
public
void
put
(
ProtectionDomain
pd
,
PermissionCollection
pc
)
{
map
.
put
((
pd
==
null
?
null
:
pd
.
key
),
pc
);
}
@Override
public
PermissionCollection
get
(
ProtectionDomain
pd
)
{
processQueue
(
queue
,
pdMap
);
WeakProtectionDomainKey
weakPd
=
new
WeakProtectionDomainKey
(
pd
);
SoftReference
<
PermissionCollection
>
sr
=
pdMap
.
get
(
weakPd
);
return
(
sr
==
null
)
?
null
:
sr
.
get
();
}
/**
* Removes weak keys from the map that have been enqueued
* on the reference queue and are no longer in use.
*/
private
static
void
processQueue
(
ReferenceQueue
<
Key
>
queue
,
ConcurrentHashMap
<?
extends
WeakReference
<
Key
>,
?>
pdMap
)
{
Reference
<?
extends
Key
>
ref
;
while
((
ref
=
queue
.
poll
())
!=
null
)
{
pdMap
.
remove
(
ref
);
}
}
}
/**
* A weak key for a ProtectionDomain.
*/
private
static
class
WeakProtectionDomainKey
extends
WeakReference
<
Key
>
{
/**
* Saved value of the referent's identity hash code, to maintain
* a consistent hash code after the referent has been cleared
*/
private
final
int
hash
;
/**
* A key representing a null ProtectionDomain.
*/
private
static
final
Key
NULL_KEY
=
new
Key
();
/**
* Create a new WeakProtectionDomain with the specified domain and
* registered with a queue.
*/
WeakProtectionDomainKey
(
ProtectionDomain
pd
,
ReferenceQueue
<
Key
>
rq
)
{
this
((
pd
==
null
?
NULL_KEY
:
pd
.
key
),
rq
);
}
WeakProtectionDomainKey
(
ProtectionDomain
pd
)
{
this
(
pd
==
null
?
NULL_KEY
:
pd
.
key
);
}
private
WeakProtectionDomainKey
(
Key
key
,
ReferenceQueue
<
Key
>
rq
)
{
super
(
key
,
rq
);
hash
=
key
.
hashCode
();
}
private
WeakProtectionDomainKey
(
Key
key
)
{
super
(
key
);
hash
=
key
.
hashCode
();
return
pd
==
null
?
map
.
get
(
null
)
:
map
.
get
(
pd
.
key
);
}
/**
* Returns the identity hash code of the original referent.
*/
@Override
public
int
hashCode
()
{
return
hash
;
};
}
/**
* Returns true if the given object is an identical
* WeakProtectionDomainKey instance, or, if this object's referent
* has not been cleared and the given object is another
* WeakProtectionDomainKey instance with an identical non-null
* referent as this one.
*/
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
==
this
)
{
return
true
;
}
if
(
obj
instanceof
WeakProtectionDomainKey
)
{
Object
referent
=
get
();
return
(
referent
!=
null
)
&&
(
referent
==
((
WeakProtectionDomainKey
)
obj
).
get
());
}
else
{
return
false
;
}
public
boolean
getStaticPermissionsField
(
ProtectionDomain
pd
)
{
return
pd
.
staticPermissions
;
}
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录