Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5ff1a97e
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看板
提交
5ff1a97e
编写于
4月 19, 2013
作者:
S
sundar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8006611: Improve scripting
Reviewed-by: mchung
上级
ca970328
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
2 addition
and
51 deletion
+2
-51
src/share/classes/javax/script/ScriptEngineManager.java
src/share/classes/javax/script/ScriptEngineManager.java
+2
-51
未找到文件。
src/share/classes/javax/script/ScriptEngineManager.java
浏览文件 @
5ff1a97e
...
@@ -28,9 +28,6 @@ import java.util.*;
...
@@ -28,9 +28,6 @@ import java.util.*;
import
java.security.*
;
import
java.security.*
;
import
java.util.ServiceLoader
;
import
java.util.ServiceLoader
;
import
java.util.ServiceConfigurationError
;
import
java.util.ServiceConfigurationError
;
import
sun.reflect.CallerSensitive
;
import
sun.reflect.Reflection
;
import
sun.security.util.SecurityConstants
;
/**
/**
* The <code>ScriptEngineManager</code> implements a discovery and instantiation
* The <code>ScriptEngineManager</code> implements a discovery and instantiation
...
@@ -54,23 +51,14 @@ import sun.security.util.SecurityConstants;
...
@@ -54,23 +51,14 @@ import sun.security.util.SecurityConstants;
public
class
ScriptEngineManager
{
public
class
ScriptEngineManager
{
private
static
final
boolean
DEBUG
=
false
;
private
static
final
boolean
DEBUG
=
false
;
/**
/**
* If the thread context ClassLoader can be accessed by the caller,
* The effect of calling this constructor is the same as calling
* then the effect of calling this constructor is the same as calling
* <code>ScriptEngineManager(Thread.currentThread().getContextClassLoader())</code>.
* <code>ScriptEngineManager(Thread.currentThread().getContextClassLoader())</code>.
* Otherwise, the effect is the same as calling <code>ScriptEngineManager(null)</code>.
*
*
* @see java.lang.Thread#getContextClassLoader
* @see java.lang.Thread#getContextClassLoader
*/
*/
@CallerSensitive
public
ScriptEngineManager
()
{
public
ScriptEngineManager
()
{
ClassLoader
ctxtLoader
=
Thread
.
currentThread
().
getContextClassLoader
();
ClassLoader
ctxtLoader
=
Thread
.
currentThread
().
getContextClassLoader
();
if
(
canCallerAccessLoader
(
ctxtLoader
,
Reflection
.
getCallerClass
()))
{
if
(
DEBUG
)
System
.
out
.
println
(
"using "
+
ctxtLoader
);
init
(
ctxtLoader
);
init
(
ctxtLoader
);
}
else
{
if
(
DEBUG
)
System
.
out
.
println
(
"using bootstrap loader"
);
init
(
null
);
}
}
}
/**
/**
...
@@ -420,41 +408,4 @@ public class ScriptEngineManager {
...
@@ -420,41 +408,4 @@ public class ScriptEngineManager {
/** Global bindings associated with script engines created by this manager. */
/** Global bindings associated with script engines created by this manager. */
private
Bindings
globalScope
;
private
Bindings
globalScope
;
private
boolean
canCallerAccessLoader
(
ClassLoader
loader
,
Class
<?>
caller
)
{
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
!=
null
)
{
ClassLoader
callerLoader
=
getClassLoader
(
caller
);
if
(!
sun
.
misc
.
VM
.
isSystemDomainLoader
(
callerLoader
))
{
if
(
loader
!=
callerLoader
||
!
isAncestor
(
loader
,
callerLoader
))
{
try
{
sm
.
checkPermission
(
SecurityConstants
.
GET_CLASSLOADER_PERMISSION
);
}
catch
(
SecurityException
exp
)
{
if
(
DEBUG
)
exp
.
printStackTrace
();
return
false
;
}
}
// else fallthru..
}
// else fallthru..
}
// else fallthru..
return
true
;
}
// Note that this code is same as ClassLoader.getClassLoader().
// But, that method is package private and hence we can't call here.
private
ClassLoader
getClassLoader
(
Class
<?>
caller
)
{
if
(
caller
==
null
)
{
return
null
;
}
return
caller
.
getClassLoader
();
}
// is cl1 ancestor of cl2?
private
boolean
isAncestor
(
ClassLoader
cl1
,
ClassLoader
cl2
)
{
do
{
cl2
=
cl2
.
getParent
();
if
(
cl1
==
cl2
)
return
true
;
}
while
(
cl2
!=
null
);
return
false
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录