Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
90d0c797
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看板
提交
90d0c797
编写于
5月 08, 2014
作者:
C
coleenp
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8015256: Better class accessibility
Summary: Improve protection domain check in forName() Reviewed-by: mchung, acorn, jdn
上级
be69a164
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
32 addition
and
15 deletion
+32
-15
src/share/classes/java/lang/Class.java
src/share/classes/java/lang/Class.java
+15
-10
src/share/javavm/export/jvm.h
src/share/javavm/export/jvm.h
+14
-1
src/share/native/java/lang/Class.c
src/share/native/java/lang/Class.c
+3
-4
未找到文件。
src/share/classes/java/lang/Class.java
浏览文件 @
90d0c797
/*
/*
* Copyright (c) 1994, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 201
4
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -256,8 +256,8 @@ public final class Class<T> implements java.io.Serializable,
...
@@ -256,8 +256,8 @@ public final class Class<T> implements java.io.Serializable,
@CallerSensitive
@CallerSensitive
public
static
Class
<?>
forName
(
String
className
)
public
static
Class
<?>
forName
(
String
className
)
throws
ClassNotFoundException
{
throws
ClassNotFoundException
{
return
forName0
(
className
,
true
,
Class
<?>
caller
=
Reflection
.
getCallerClass
();
ClassLoader
.
getClassLoader
(
Reflection
.
getCallerClass
())
);
return
forName0
(
className
,
true
,
ClassLoader
.
getClassLoader
(
caller
),
caller
);
}
}
...
@@ -327,22 +327,27 @@ public final class Class<T> implements java.io.Serializable,
...
@@ -327,22 +327,27 @@ public final class Class<T> implements java.io.Serializable,
ClassLoader
loader
)
ClassLoader
loader
)
throws
ClassNotFoundException
throws
ClassNotFoundException
{
{
if
(
sun
.
misc
.
VM
.
isSystemDomainLoader
(
loader
))
{
Class
<?>
caller
=
null
;
SecurityManager
sm
=
System
.
getSecurityManager
();
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
!=
null
)
{
if
(
sm
!=
null
)
{
ClassLoader
ccl
=
ClassLoader
.
getClassLoader
(
Reflection
.
getCallerClass
());
// Reflective call to get caller class is only needed if a security manager
// is present. Avoid the overhead of making this call otherwise.
caller
=
Reflection
.
getCallerClass
();
if
(
sun
.
misc
.
VM
.
isSystemDomainLoader
(
loader
))
{
ClassLoader
ccl
=
ClassLoader
.
getClassLoader
(
caller
);
if
(!
sun
.
misc
.
VM
.
isSystemDomainLoader
(
ccl
))
{
if
(!
sun
.
misc
.
VM
.
isSystemDomainLoader
(
ccl
))
{
sm
.
checkPermission
(
sm
.
checkPermission
(
SecurityConstants
.
GET_CLASSLOADER_PERMISSION
);
SecurityConstants
.
GET_CLASSLOADER_PERMISSION
);
}
}
}
}
}
}
return
forName0
(
name
,
initialize
,
loader
);
return
forName0
(
name
,
initialize
,
loader
,
caller
);
}
}
/** Called after security checks have been made. */
/** Called after security check
for system loader access check
s have been made. */
private
static
native
Class
<?>
forName0
(
String
name
,
boolean
initialize
,
private
static
native
Class
<?>
forName0
(
String
name
,
boolean
initialize
,
ClassLoader
loader
)
ClassLoader
loader
,
Class
<?>
caller
)
throws
ClassNotFoundException
;
throws
ClassNotFoundException
;
/**
/**
...
...
src/share/javavm/export/jvm.h
浏览文件 @
90d0c797
/*
/*
* Copyright (c) 1997, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
4
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -385,6 +385,19 @@ JVM_ResolveClass(JNIEnv *env, jclass cls);
...
@@ -385,6 +385,19 @@ JVM_ResolveClass(JNIEnv *env, jclass cls);
JNIEXPORT
jclass
JNICALL
JNIEXPORT
jclass
JNICALL
JVM_FindClassFromBootLoader
(
JNIEnv
*
env
,
const
char
*
name
);
JVM_FindClassFromBootLoader
(
JNIEnv
*
env
,
const
char
*
name
);
/*
* Find a class from a given class loader. Throws ClassNotFoundException.
* name: name of class
* init: whether initialization is done
* loader: class loader to look up the class. This may not be the same as the caller's
* class loader.
* caller: initiating class. The initiating class may be null when a security
* manager is not installed.
*/
JNIEXPORT
jclass
JNICALL
JVM_FindClassFromCaller
(
JNIEnv
*
env
,
const
char
*
name
,
jboolean
init
,
jobject
loader
,
jclass
caller
);
/*
/*
* Find a class from a given class loader. Throw ClassNotFoundException
* Find a class from a given class loader. Throw ClassNotFoundException
* or NoClassDefFoundError depending on the value of the last
* or NoClassDefFoundError depending on the value of the last
...
...
src/share/native/java/lang/Class.c
浏览文件 @
90d0c797
/*
/*
* Copyright (c) 1994, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 201
4
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -97,7 +97,7 @@ Java_java_lang_Class_registerNatives(JNIEnv *env, jclass cls)
...
@@ -97,7 +97,7 @@ Java_java_lang_Class_registerNatives(JNIEnv *env, jclass cls)
JNIEXPORT
jclass
JNICALL
JNIEXPORT
jclass
JNICALL
Java_java_lang_Class_forName0
(
JNIEnv
*
env
,
jclass
this
,
jstring
classname
,
Java_java_lang_Class_forName0
(
JNIEnv
*
env
,
jclass
this
,
jstring
classname
,
jboolean
initialize
,
jobject
loader
)
jboolean
initialize
,
jobject
loader
,
jclass
caller
)
{
{
char
*
clname
;
char
*
clname
;
jclass
cls
=
0
;
jclass
cls
=
0
;
...
@@ -135,8 +135,7 @@ Java_java_lang_Class_forName0(JNIEnv *env, jclass this, jstring classname,
...
@@ -135,8 +135,7 @@ Java_java_lang_Class_forName0(JNIEnv *env, jclass this, jstring classname,
goto
done
;
goto
done
;
}
}
cls
=
JVM_FindClassFromClassLoader
(
env
,
clname
,
initialize
,
cls
=
JVM_FindClassFromCaller
(
env
,
clname
,
initialize
,
loader
,
caller
);
loader
,
JNI_FALSE
);
done:
done:
if
(
clname
!=
buf
)
{
if
(
clname
!=
buf
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录