Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4ea7c751
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看板
提交
4ea7c751
编写于
12月 02, 2011
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7116946: JSSecurityManager should use java.util.ServiceLoader to lookup service providers
Reviewed-by: prr
上级
7adf5e07
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
22 deletion
+20
-22
src/share/classes/com/sun/media/sound/JSSecurityManager.java
src/share/classes/com/sun/media/sound/JSSecurityManager.java
+20
-22
未找到文件。
src/share/classes/com/sun/media/sound/JSSecurityManager.java
浏览文件 @
4ea7c751
...
@@ -34,15 +34,13 @@ import java.util.ArrayList;
...
@@ -34,15 +34,13 @@ import java.util.ArrayList;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.ServiceLoader
;
import
java.security.AccessController
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
java.security.PrivilegedAction
;
import
javax.sound.sampled.AudioPermission
;
import
javax.sound.sampled.AudioPermission
;
import
sun.misc.Service
;
/** Managing security in the Java Sound implementation.
/** Managing security in the Java Sound implementation.
* This class contains all code that uses and is used by
* This class contains all code that uses and is used by
* SecurityManager.doPrivileged().
* SecurityManager.doPrivileged().
...
@@ -80,8 +78,8 @@ class JSSecurityManager {
...
@@ -80,8 +78,8 @@ class JSSecurityManager {
try
{
try
{
if
(
hasSecurityManager
())
{
if
(
hasSecurityManager
())
{
if
(
Printer
.
debug
)
Printer
.
debug
(
"using security manager to load library"
);
if
(
Printer
.
debug
)
Printer
.
debug
(
"using security manager to load library"
);
PrivilegedAction
action
=
new
PrivilegedAction
()
{
PrivilegedAction
<
Void
>
action
=
new
PrivilegedAction
<
Void
>
()
{
public
Object
run
()
{
public
Void
run
()
{
System
.
loadLibrary
(
libName
);
System
.
loadLibrary
(
libName
);
return
null
;
return
null
;
}
}
...
@@ -104,8 +102,8 @@ class JSSecurityManager {
...
@@ -104,8 +102,8 @@ class JSSecurityManager {
if
(
hasSecurityManager
())
{
if
(
hasSecurityManager
())
{
if
(
Printer
.
debug
)
Printer
.
debug
(
"using JDK 1.2 security to get property"
);
if
(
Printer
.
debug
)
Printer
.
debug
(
"using JDK 1.2 security to get property"
);
try
{
try
{
PrivilegedAction
action
=
new
PrivilegedAction
()
{
PrivilegedAction
<
String
>
action
=
new
PrivilegedAction
<
String
>
()
{
public
Object
run
()
{
public
String
run
()
{
try
{
try
{
return
System
.
getProperty
(
propertyName
);
return
System
.
getProperty
(
propertyName
);
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
...
@@ -113,7 +111,7 @@ class JSSecurityManager {
...
@@ -113,7 +111,7 @@ class JSSecurityManager {
}
}
}
}
};
};
propertyValue
=
(
String
)
AccessController
.
doPrivileged
(
action
);
propertyValue
=
AccessController
.
doPrivileged
(
action
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
if
(
Printer
.
debug
)
Printer
.
debug
(
"not using JDK 1.2 security to get properties"
);
if
(
Printer
.
debug
)
Printer
.
debug
(
"not using JDK 1.2 security to get properties"
);
propertyValue
=
System
.
getProperty
(
propertyName
);
propertyValue
=
System
.
getProperty
(
propertyName
);
...
@@ -142,8 +140,8 @@ class JSSecurityManager {
...
@@ -142,8 +140,8 @@ class JSSecurityManager {
if
(
hasSecurityManager
())
{
if
(
hasSecurityManager
())
{
try
{
try
{
// invoke the privileged action using 1.2 security
// invoke the privileged action using 1.2 security
PrivilegedAction
action
=
new
PrivilegedAction
()
{
PrivilegedAction
<
Void
>
action
=
new
PrivilegedAction
<
Void
>
()
{
public
Object
run
()
{
public
Void
run
()
{
loadPropertiesImpl
(
properties
,
filename
);
loadPropertiesImpl
(
properties
,
filename
);
return
null
;
return
null
;
}
}
...
@@ -197,8 +195,8 @@ class JSSecurityManager {
...
@@ -197,8 +195,8 @@ class JSSecurityManager {
if
(
hasSecurityManager
())
{
if
(
hasSecurityManager
())
{
try
{
try
{
// invoke the privileged action using 1.2 security
// invoke the privileged action using 1.2 security
PrivilegedAction
action
=
new
PrivilegedAction
()
{
PrivilegedAction
<
ThreadGroup
>
action
=
new
PrivilegedAction
<
ThreadGroup
>
()
{
public
Object
run
()
{
public
ThreadGroup
run
()
{
try
{
try
{
return
getTopmostThreadGroupImpl
();
return
getTopmostThreadGroupImpl
();
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
...
@@ -206,7 +204,7 @@ class JSSecurityManager {
...
@@ -206,7 +204,7 @@ class JSSecurityManager {
}
}
}
}
};
};
topmostThreadGroup
=
(
ThreadGroup
)
AccessController
.
doPrivileged
(
action
);
topmostThreadGroup
=
AccessController
.
doPrivileged
(
action
);
if
(
Printer
.
debug
)
Printer
.
debug
(
"Got topmost thread group with JDK 1.2 security"
);
if
(
Printer
.
debug
)
Printer
.
debug
(
"Got topmost thread group with JDK 1.2 security"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
if
(
Printer
.
debug
)
Printer
.
debug
(
"Exception getting topmost thread group with JDK 1.2 security"
);
if
(
Printer
.
debug
)
Printer
.
debug
(
"Exception getting topmost thread group with JDK 1.2 security"
);
...
@@ -240,8 +238,8 @@ class JSSecurityManager {
...
@@ -240,8 +238,8 @@ class JSSecurityManager {
final
boolean
doStart
)
{
final
boolean
doStart
)
{
Thread
thread
=
null
;
Thread
thread
=
null
;
if
(
hasSecurityManager
())
{
if
(
hasSecurityManager
())
{
PrivilegedAction
action
=
new
PrivilegedAction
()
{
PrivilegedAction
<
Thread
>
action
=
new
PrivilegedAction
<
Thread
>
()
{
public
Object
run
()
{
public
Thread
run
()
{
try
{
try
{
return
createThreadImpl
(
runnable
,
threadName
,
return
createThreadImpl
(
runnable
,
threadName
,
isDaemon
,
priority
,
isDaemon
,
priority
,
...
@@ -251,7 +249,7 @@ class JSSecurityManager {
...
@@ -251,7 +249,7 @@ class JSSecurityManager {
}
}
}
}
};
};
thread
=
(
Thread
)
AccessController
.
doPrivileged
(
action
);
thread
=
AccessController
.
doPrivileged
(
action
);
if
(
Printer
.
debug
)
Printer
.
debug
(
"created thread with JDK 1.2 security"
);
if
(
Printer
.
debug
)
Printer
.
debug
(
"created thread with JDK 1.2 security"
);
}
else
{
}
else
{
if
(
Printer
.
debug
)
Printer
.
debug
(
"not using JDK 1.2 security"
);
if
(
Printer
.
debug
)
Printer
.
debug
(
"not using JDK 1.2 security"
);
...
@@ -282,11 +280,11 @@ class JSSecurityManager {
...
@@ -282,11 +280,11 @@ class JSSecurityManager {
}
}
static
List
getProviders
(
final
Class
providerClass
)
{
static
<
T
>
List
<
T
>
getProviders
(
final
Class
<
T
>
providerClass
)
{
List
p
=
new
ArrayList
();
List
<
T
>
p
=
new
ArrayList
<>
();
// Service
.providers(Class) just creates "lazy" iterator instance
,
// Service
Loader creates "lazy" iterator instance, so it doesn't
,
//
so it doesn't
require do be called from privileged section
// require do be called from privileged section
final
Iterator
ps
=
Service
.
providers
(
providerClass
);
final
Iterator
<
T
>
ps
=
ServiceLoader
.
load
(
providerClass
).
iterator
(
);
// the iterator's hasNext() method looks through classpath for
// the iterator's hasNext() method looks through classpath for
// the provider class names, so it requires read permissions
// the provider class names, so it requires read permissions
...
@@ -301,7 +299,7 @@ class JSSecurityManager {
...
@@ -301,7 +299,7 @@ class JSSecurityManager {
// the iterator's next() method creates instances of the
// the iterator's next() method creates instances of the
// providers and it should be called in the current security
// providers and it should be called in the current security
// context
// context
Object
provider
=
ps
.
next
();
T
provider
=
ps
.
next
();
if
(
providerClass
.
isInstance
(
provider
))
{
if
(
providerClass
.
isInstance
(
provider
))
{
// $$mp 2003-08-22
// $$mp 2003-08-22
// Always adding at the beginning reverses the
// Always adding at the beginning reverses the
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录