Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
fbe11642
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看板
提交
fbe11642
编写于
7月 03, 2009
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6329581: RFE: LTP: java.beans.XMLEncoder does not manage ClassLoader.
Reviewed-by: rupashka, alexp
上级
56e77888
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
86 addition
and
9 deletion
+86
-9
src/share/classes/java/beans/Encoder.java
src/share/classes/java/beans/Encoder.java
+5
-6
src/share/classes/java/beans/MetaData.java
src/share/classes/java/beans/MetaData.java
+4
-2
src/share/classes/java/beans/Statement.java
src/share/classes/java/beans/Statement.java
+2
-1
test/java/beans/XMLEncoder/6329581/Test6329581.java
test/java/beans/XMLEncoder/6329581/Test6329581.java
+75
-0
未找到文件。
src/share/classes/java/beans/Encoder.java
浏览文件 @
fbe11642
...
@@ -246,12 +246,11 @@ public class Encoder {
...
@@ -246,12 +246,11 @@ public class Encoder {
for
(
int
i
=
0
;
i
<
oldArgs
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
oldArgs
.
length
;
i
++)
{
newArgs
[
i
]
=
writeObject1
(
oldArgs
[
i
]);
newArgs
[
i
]
=
writeObject1
(
oldArgs
[
i
]);
}
}
if
(
oldExp
.
getClass
()
==
Statement
.
class
)
{
Statement
newExp
=
Statement
.
class
.
equals
(
oldExp
.
getClass
())
return
new
Statement
(
newTarget
,
oldExp
.
getMethodName
(),
newArgs
);
?
new
Statement
(
newTarget
,
oldExp
.
getMethodName
(),
newArgs
)
}
:
new
Expression
(
newTarget
,
oldExp
.
getMethodName
(),
newArgs
);
else
{
newExp
.
loader
=
oldExp
.
loader
;
return
new
Expression
(
newTarget
,
oldExp
.
getMethodName
(),
newArgs
);
return
newExp
;
}
}
}
/**
/**
...
...
src/share/classes/java/beans/MetaData.java
浏览文件 @
fbe11642
/*
/*
* Copyright 2000-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-200
9
Sun Microsystems, Inc. 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
...
@@ -219,7 +219,9 @@ class java_lang_Class_PersistenceDelegate extends PersistenceDelegate {
...
@@ -219,7 +219,9 @@ class java_lang_Class_PersistenceDelegate extends PersistenceDelegate {
return
new
Expression
(
oldInstance
,
String
.
class
,
"getClass"
,
new
Object
[]{});
return
new
Expression
(
oldInstance
,
String
.
class
,
"getClass"
,
new
Object
[]{});
}
}
else
{
else
{
return
new
Expression
(
oldInstance
,
Class
.
class
,
"forName"
,
new
Object
[]{
c
.
getName
()});
Expression
newInstance
=
new
Expression
(
oldInstance
,
Class
.
class
,
"forName"
,
new
Object
[]
{
c
.
getName
()
});
newInstance
.
loader
=
c
.
getClassLoader
();
return
newInstance
;
}
}
}
}
}
}
...
...
src/share/classes/java/beans/Statement.java
浏览文件 @
fbe11642
...
@@ -66,6 +66,7 @@ public class Statement {
...
@@ -66,6 +66,7 @@ public class Statement {
Object
target
;
Object
target
;
String
methodName
;
String
methodName
;
Object
[]
arguments
;
Object
[]
arguments
;
ClassLoader
loader
;
/**
/**
* Creates a new <code>Statement</code> object with a <code>target</code>,
* Creates a new <code>Statement</code> object with a <code>target</code>,
...
@@ -157,7 +158,7 @@ public class Statement {
...
@@ -157,7 +158,7 @@ public class Statement {
// of core from a class inside core. Special
// of core from a class inside core. Special
// case this method.
// case this method.
if
(
target
==
Class
.
class
&&
methodName
.
equals
(
"forName"
))
{
if
(
target
==
Class
.
class
&&
methodName
.
equals
(
"forName"
))
{
return
ClassFinder
.
resolveClass
((
String
)
arguments
[
0
]);
return
ClassFinder
.
resolveClass
((
String
)
arguments
[
0
]
,
this
.
loader
);
}
}
Class
[]
argClasses
=
new
Class
[
arguments
.
length
];
Class
[]
argClasses
=
new
Class
[
arguments
.
length
];
for
(
int
i
=
0
;
i
<
arguments
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
arguments
.
length
;
i
++)
{
...
...
test/java/beans/XMLEncoder/6329581/Test6329581.java
0 → 100644
浏览文件 @
fbe11642
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6329581
* @summary Tests encoding of a class with custom ClassLoader
* @author Sergey Malenkov
*/
import
java.beans.ExceptionListener
;
import
java.beans.XMLDecoder
;
import
java.beans.XMLEncoder
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.net.URL
;
import
java.net.URLClassLoader
;
public
class
Test6329581
implements
ExceptionListener
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ExceptionListener
listener
=
new
Test6329581
();
// write bean to byte array
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
XMLEncoder
encoder
=
new
XMLEncoder
(
out
);
encoder
.
setExceptionListener
(
listener
);
encoder
.
writeObject
(
getClassLoader
(
"beans.jar"
).
loadClass
(
"test.Bean"
).
newInstance
());
encoder
.
close
();
// read bean from byte array
ByteArrayInputStream
in
=
new
ByteArrayInputStream
(
out
.
toByteArray
());
XMLDecoder
decoder
=
new
XMLDecoder
(
in
,
null
,
listener
,
getClassLoader
(
"beans.jar"
));
Object
object
=
decoder
.
readObject
();
decoder
.
close
();
if
(!
object
.
getClass
().
getClassLoader
().
getClass
().
equals
(
URLClassLoader
.
class
))
{
throw
new
Error
(
"bean is loaded with unexpected class loader"
);
}
}
private
static
ClassLoader
getClassLoader
(
String
name
)
throws
Exception
{
StringBuilder
sb
=
new
StringBuilder
(
256
);
sb
.
append
(
"file:"
);
sb
.
append
(
System
.
getProperty
(
"test.src"
,
"."
));
sb
.
append
(
File
.
separatorChar
);
sb
.
append
(
name
);
URL
[]
url
=
{
new
URL
(
sb
.
toString
())
};
return
new
URLClassLoader
(
url
);
}
public
void
exceptionThrown
(
Exception
exception
)
{
throw
new
Error
(
"unexpected exception"
,
exception
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录