Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
037fa367
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看板
提交
037fa367
编写于
12月 07, 2009
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6902010: (cl) Delay initialization of ClassLoader.parallelLoaders
Reviewed-by: forax, mchung, valeriep
上级
9c9a030f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
27 deletion
+48
-27
src/share/classes/java/lang/ClassLoader.java
src/share/classes/java/lang/ClassLoader.java
+48
-27
未找到文件。
src/share/classes/java/lang/ClassLoader.java
浏览文件 @
037fa367
...
@@ -175,15 +175,8 @@ import sun.security.util.SecurityConstants;
...
@@ -175,15 +175,8 @@ import sun.security.util.SecurityConstants;
public
abstract
class
ClassLoader
{
public
abstract
class
ClassLoader
{
private
static
native
void
registerNatives
();
private
static
native
void
registerNatives
();
// Set of classes which are registered as parallel capable class loaders
private
static
final
Set
<
Class
<?
extends
ClassLoader
>>
parallelLoaders
=
Collections
.
newSetFromMap
(
Collections
.
synchronizedMap
(
new
WeakHashMap
<
Class
<?
extends
ClassLoader
>,
Boolean
>()));
static
{
static
{
registerNatives
();
registerNatives
();
parallelLoaders
.
add
(
ClassLoader
.
class
);
}
}
// The parent class loader for delegation
// The parent class loader for delegation
...
@@ -191,6 +184,52 @@ public abstract class ClassLoader {
...
@@ -191,6 +184,52 @@ public abstract class ClassLoader {
// must be added *after* it.
// must be added *after* it.
private
final
ClassLoader
parent
;
private
final
ClassLoader
parent
;
/**
* Encapsulates the set of parallel capable loader types.
*/
private
static
class
ParallelLoaders
{
private
ParallelLoaders
()
{}
// the set of parallel capable loader types
private
static
final
Set
<
Class
<?
extends
ClassLoader
>>
loaderTypes
=
Collections
.
newSetFromMap
(
new
WeakHashMap
<
Class
<?
extends
ClassLoader
>,
Boolean
>());
static
{
synchronized
(
loaderTypes
)
{
loaderTypes
.
add
(
ClassLoader
.
class
);
}
}
/**
* Registers the given class loader type as parallel capabale.
* Returns {@code true} is successfully registered; {@code false} if
* loader's super class is not registered.
*/
static
boolean
register
(
Class
<?
extends
ClassLoader
>
c
)
{
synchronized
(
loaderTypes
)
{
if
(
loaderTypes
.
contains
(
c
.
getSuperclass
()))
{
// register the class loader as parallel capable
// if and only if all of its super classes are.
// Note: given current classloading sequence, if
// the immediate super class is parallel capable,
// all the super classes higher up must be too.
loaderTypes
.
add
(
c
);
return
true
;
}
else
{
return
false
;
}
}
}
/**
* Returns {@code true} if the given class loader type is
* registered as parallel capable.
*/
static
boolean
isRegistered
(
Class
<?
extends
ClassLoader
>
c
)
{
synchronized
(
loaderTypes
)
{
return
loaderTypes
.
contains
(
c
);
}
}
}
// Maps class name to the corresponding lock object when the current
// Maps class name to the corresponding lock object when the current
// class loader is parallel capable.
// class loader is parallel capable.
// Note: VM also uses this field to decide if the current class loader
// Note: VM also uses this field to decide if the current class loader
...
@@ -237,7 +276,7 @@ public abstract class ClassLoader {
...
@@ -237,7 +276,7 @@ public abstract class ClassLoader {
private
ClassLoader
(
Void
unused
,
ClassLoader
parent
)
{
private
ClassLoader
(
Void
unused
,
ClassLoader
parent
)
{
this
.
parent
=
parent
;
this
.
parent
=
parent
;
if
(
parallelLoaders
.
contains
(
this
.
getClass
()))
{
if
(
ParallelLoaders
.
isRegistered
(
this
.
getClass
()))
{
parallelLockMap
=
new
ConcurrentHashMap
<
String
,
Object
>();
parallelLockMap
=
new
ConcurrentHashMap
<
String
,
Object
>();
package2certs
=
new
ConcurrentHashMap
<
String
,
Certificate
[]>();
package2certs
=
new
ConcurrentHashMap
<
String
,
Certificate
[]>();
domains
=
domains
=
...
@@ -1194,24 +1233,7 @@ public abstract class ClassLoader {
...
@@ -1194,24 +1233,7 @@ public abstract class ClassLoader {
* @since 1.7
* @since 1.7
*/
*/
protected
static
boolean
registerAsParallelCapable
()
{
protected
static
boolean
registerAsParallelCapable
()
{
Class
<?
extends
ClassLoader
>
caller
=
getCaller
(
1
);
return
ParallelLoaders
.
register
(
getCaller
(
1
));
Class
superCls
=
caller
.
getSuperclass
();
boolean
result
=
false
;
// Explicit synchronization needed for composite action
synchronized
(
parallelLoaders
)
{
if
(!
parallelLoaders
.
contains
(
caller
))
{
if
(
parallelLoaders
.
contains
(
superCls
))
{
// register the immediate caller as parallel capable
// if and only if all of its super classes are.
// Note: given current classloading sequence, if
// the immediate super class is parallel capable,
// all the super classes higher up must be too.
result
=
true
;
parallelLoaders
.
add
(
caller
);
}
}
else
result
=
true
;
}
return
result
;
}
}
/**
/**
...
@@ -2174,4 +2196,3 @@ class SystemClassLoaderAction
...
@@ -2174,4 +2196,3 @@ class SystemClassLoaderAction
return
sys
;
return
sys
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录