Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c702db81
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c702db81
编写于
3月 08, 2013
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8009645: ClassFileTransformer hooks in ClassLoader no longer required
Reviewed-by: mchung, iris
上级
f63c3865
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
91 deletion
+20
-91
src/share/classes/java/lang/ClassLoader.java
src/share/classes/java/lang/ClassLoader.java
+2
-59
src/share/classes/sun/misc/ClassFileTransformer.java
src/share/classes/sun/misc/ClassFileTransformer.java
+18
-32
未找到文件。
src/share/classes/java/lang/ClassLoader.java
浏览文件 @
c702db81
...
...
@@ -51,7 +51,6 @@ import java.util.Vector;
import
java.util.Hashtable
;
import
java.util.WeakHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
sun.misc.ClassFileTransformer
;
import
sun.misc.CompoundEnumeration
;
import
sun.misc.Resource
;
import
sun.misc.URLClassPath
;
...
...
@@ -669,41 +668,6 @@ public abstract class ClassLoader {
return
source
;
}
private
Class
<?>
defineTransformedClass
(
String
name
,
byte
[]
b
,
int
off
,
int
len
,
ProtectionDomain
pd
,
ClassFormatError
cfe
,
String
source
)
throws
ClassFormatError
{
// Class format error - try to transform the bytecode and
// define the class again
//
ClassFileTransformer
[]
transformers
=
ClassFileTransformer
.
getTransformers
();
Class
<?>
c
=
null
;
if
(
transformers
!=
null
)
{
for
(
ClassFileTransformer
transformer
:
transformers
)
{
try
{
// Transform byte code using transformer
byte
[]
tb
=
transformer
.
transform
(
b
,
off
,
len
);
c
=
defineClass1
(
name
,
tb
,
0
,
tb
.
length
,
pd
,
source
);
break
;
}
catch
(
ClassFormatError
cfe2
)
{
// If ClassFormatError occurs, try next transformer
}
}
}
// Rethrow original ClassFormatError if unable to transform
// bytecode to well-formed
//
if
(
c
==
null
)
throw
cfe
;
return
c
;
}
private
void
postDefineClass
(
Class
<?>
c
,
ProtectionDomain
pd
)
{
if
(
pd
.
getCodeSource
()
!=
null
)
{
...
...
@@ -783,17 +747,8 @@ public abstract class ClassLoader {
throws
ClassFormatError
{
protectionDomain
=
preDefineClass
(
name
,
protectionDomain
);
Class
<?>
c
=
null
;
String
source
=
defineClassSourceLocation
(
protectionDomain
);
try
{
c
=
defineClass1
(
name
,
b
,
off
,
len
,
protectionDomain
,
source
);
}
catch
(
ClassFormatError
cfe
)
{
c
=
defineTransformedClass
(
name
,
b
,
off
,
len
,
protectionDomain
,
cfe
,
source
);
}
Class
<?>
c
=
defineClass1
(
name
,
b
,
off
,
len
,
protectionDomain
,
source
);
postDefineClass
(
c
,
protectionDomain
);
return
c
;
}
...
...
@@ -881,20 +836,8 @@ public abstract class ClassLoader {
}
protectionDomain
=
preDefineClass
(
name
,
protectionDomain
);
Class
<?>
c
=
null
;
String
source
=
defineClassSourceLocation
(
protectionDomain
);
try
{
c
=
defineClass2
(
name
,
b
,
b
.
position
(),
len
,
protectionDomain
,
source
);
}
catch
(
ClassFormatError
cfe
)
{
byte
[]
tb
=
new
byte
[
len
];
b
.
get
(
tb
);
// get bytes out of byte buffer.
c
=
defineTransformedClass
(
name
,
tb
,
0
,
len
,
protectionDomain
,
cfe
,
source
);
}
Class
<?>
c
=
defineClass2
(
name
,
b
,
b
.
position
(),
len
,
protectionDomain
,
source
);
postDefineClass
(
c
,
protectionDomain
);
return
c
;
}
...
...
src/share/classes/sun/misc/ClassFileTransformer.java
浏览文件 @
c702db81
...
...
@@ -25,43 +25,31 @@
package
sun.misc
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* This is an abstract base class which is called by java.lang.ClassLoader
* when ClassFormatError is thrown inside defineClass().
*
* The purpose of this class is to allow applications (e.g. Java Plug-in)
* to have a chance to transform the byte code from one form to another
* if necessary.
*
* One application of this class is used by Java Plug-in to transform
* malformed JDK 1.1 class file into a well-formed Java 2 class file
* on-the-fly, so JDK 1.1 applets with malformed class file in the
* Internet may run in Java 2 after transformation.
* This is an abstract base class originally intended to be called by
* {@code java.lang.ClassLoader} when {@code ClassFormatError} is
* thrown inside {@code defineClass()}. It is no longer hooked into
* {@code ClassLoader} and will be removed in a future release.
*
* @author Stanley Man-Kit Ho
*/
public
abstract
class
ClassFileTransformer
{
// Singleton of ClassFileTransformer
//
private
static
ArrayList
<
ClassFileTransformer
>
transformerList
@Deprecated
public
abstract
class
ClassFileTransformer
{
private
static
final
List
<
ClassFileTransformer
>
transformers
=
new
ArrayList
<
ClassFileTransformer
>();
private
static
ClassFileTransformer
[]
transformers
=
new
ClassFileTransformer
[
0
];
/**
* Add the class file transformer object.
*
* @param t Class file transformer instance
*/
public
static
void
add
(
ClassFileTransformer
t
)
{
synchronized
(
transformerList
)
{
transformerList
.
add
(
t
);
transformers
=
transformerList
.
toArray
(
new
ClassFileTransformer
[
0
]);
public
static
void
add
(
ClassFileTransformer
t
)
{
synchronized
(
transformers
)
{
transformers
.
add
(
t
);
}
}
...
...
@@ -70,13 +58,11 @@ public abstract class ClassFileTransformer
*
* @return ClassFileTransformer object array
*/
public
static
ClassFileTransformer
[]
getTransformers
()
{
// transformers is not intended to be changed frequently,
// so it is okay to not put synchronized block here
// to speed up performance.
//
return
transformers
;
public
static
ClassFileTransformer
[]
getTransformers
()
{
synchronized
(
transformers
)
{
ClassFileTransformer
[]
result
=
new
ClassFileTransformer
[
transformers
.
size
()];
return
transformers
.
toArray
(
result
);
}
}
...
...
@@ -89,5 +75,5 @@ public abstract class ClassFileTransformer
* @return Transformed byte array
*/
public
abstract
byte
[]
transform
(
byte
[]
b
,
int
off
,
int
len
)
throws
ClassFormatError
;
throws
ClassFormatError
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录