Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
73bd3791
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看板
提交
73bd3791
编写于
11月 16, 2009
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6890458: Datatransfer API should not require RMI to be present
Reviewed-by: uta
上级
a3f28874
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
107 addition
and
7 deletion
+107
-7
src/share/classes/java/awt/datatransfer/DataFlavor.java
src/share/classes/java/awt/datatransfer/DataFlavor.java
+1
-1
src/share/classes/sun/awt/datatransfer/DataTransferer.java
src/share/classes/sun/awt/datatransfer/DataTransferer.java
+106
-6
未找到文件。
src/share/classes/java/awt/datatransfer/DataFlavor.java
浏览文件 @
73bd3791
...
...
@@ -1184,7 +1184,7 @@ public class DataFlavor implements Externalizable, Cloneable {
*/
public
boolean
isRepresentationClassRemote
()
{
return
java
.
rmi
.
Remote
.
class
.
isAssignableFrom
(
representationClass
);
return
DataTransferer
.
isRemote
(
representationClass
);
}
/**
...
...
src/share/classes/sun/awt/datatransfer/DataTransferer.java
浏览文件 @
73bd3791
...
...
@@ -63,8 +63,6 @@ import java.lang.reflect.InvocationTargetException;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.rmi.MarshalledObject
;
import
java.security.AccessControlContext
;
import
java.security.AccessControlException
;
import
java.security.AccessController
;
...
...
@@ -493,6 +491,13 @@ public abstract class DataTransferer {
}
}
/**
* Returns {@code true} if the given type is a java.rmi.Remote.
*/
public
static
boolean
isRemote
(
Class
<?>
type
)
{
return
RMI
.
isRemote
(
type
);
}
/**
* Returns an Iterator which traverses a SortedSet of Strings which are
* a total order of the standard character sets supported by the JRE. The
...
...
@@ -1360,7 +1365,7 @@ search:
// Source data is an RMI object
}
else
if
(
flavor
.
isRepresentationClassRemote
())
{
MarshalledObject
mo
=
new
MarshalledObject
(
obj
);
Object
mo
=
RMI
.
new
MarshalledObject
(
obj
);
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
bos
);
oos
.
writeObject
(
mo
);
oos
.
close
();
...
...
@@ -1671,7 +1676,7 @@ search:
try
{
byte
[]
ba
=
inputStreamToByteArray
(
str
);
ObjectInputStream
ois
=
new
ObjectInputStream
(
new
ByteArrayInputStream
(
ba
));
Object
ret
=
((
MarshalledObject
)(
ois
.
readObject
())).
get
(
);
Object
ret
=
RMI
.
getMarshalledObject
(
ois
.
readObject
()
);
ois
.
close
();
str
.
close
();
return
ret
;
...
...
@@ -2669,8 +2674,12 @@ search:
Integer
.
valueOf
(
0
));
nonTextRepresentationsMap
.
put
(
java
.
io
.
Serializable
.
class
,
Integer
.
valueOf
(
1
));
nonTextRepresentationsMap
.
put
(
java
.
rmi
.
Remote
.
class
,
Integer
.
valueOf
(
2
));
Class
<?>
remoteClass
=
RMI
.
remoteClass
();
if
(
remoteClass
!=
null
)
{
nonTextRepresentationsMap
.
put
(
remoteClass
,
Integer
.
valueOf
(
2
));
}
nonTextRepresentations
=
Collections
.
unmodifiableMap
(
nonTextRepresentationsMap
);
...
...
@@ -2900,4 +2909,95 @@ search:
}
}
}
/**
* A class that provides access to java.rmi.Remote and java.rmi.MarshalledObject
* without creating a static dependency.
*/
private
static
class
RMI
{
private
static
final
Class
<?>
remoteClass
=
getClass
(
"java.rmi.Remote"
);
private
static
final
Class
<?>
marshallObjectClass
=
getClass
(
"java.rmi.MarshalledObject"
);
private
static
final
Constructor
<?>
marshallCtor
=
getConstructor
(
marshallObjectClass
,
Object
.
class
);
private
static
final
Method
marshallGet
=
getMethod
(
marshallObjectClass
,
"get"
);
private
static
Class
<?>
getClass
(
String
name
)
{
try
{
return
Class
.
forName
(
name
,
true
,
null
);
}
catch
(
ClassNotFoundException
e
)
{
return
null
;
}
}
private
static
Constructor
<?>
getConstructor
(
Class
<?>
c
,
Class
<?>...
types
)
{
try
{
return
(
c
==
null
)
?
null
:
c
.
getDeclaredConstructor
(
types
);
}
catch
(
NoSuchMethodException
x
)
{
throw
new
AssertionError
(
x
);
}
}
private
static
Method
getMethod
(
Class
<?>
c
,
String
name
,
Class
<?>...
types
)
{
try
{
return
(
c
==
null
)
?
null
:
c
.
getMethod
(
name
,
types
);
}
catch
(
NoSuchMethodException
e
)
{
throw
new
AssertionError
(
e
);
}
}
/**
* Returns {@code true} if the given class is java.rmi.Remote.
*/
static
boolean
isRemote
(
Class
<?>
c
)
{
return
(
remoteClass
==
null
)
?
null
:
remoteClass
.
isAssignableFrom
(
c
);
}
/**
* Returns java.rmi.Remote.class if RMI is present; otherwise {@code null}.
*/
static
Class
<?>
remoteClass
()
{
return
remoteClass
;
}
/**
* Returns a new MarshalledObject containing the serialized representation
* of the given object.
*/
static
Object
newMarshalledObject
(
Object
obj
)
throws
IOException
{
try
{
return
marshallCtor
.
newInstance
(
obj
);
}
catch
(
InstantiationException
x
)
{
throw
new
AssertionError
(
x
);
}
catch
(
IllegalAccessException
x
)
{
throw
new
AssertionError
(
x
);
}
catch
(
InvocationTargetException
x
)
{
Throwable
cause
=
x
.
getCause
();
if
(
cause
instanceof
IOException
)
throw
(
IOException
)
cause
;
throw
new
AssertionError
(
x
);
}
}
/**
* Returns a new copy of the contained marshalled object.
*/
static
Object
getMarshalledObject
(
Object
obj
)
throws
IOException
,
ClassNotFoundException
{
try
{
return
marshallGet
.
invoke
(
obj
);
}
catch
(
IllegalAccessException
x
)
{
throw
new
AssertionError
(
x
);
}
catch
(
InvocationTargetException
x
)
{
Throwable
cause
=
x
.
getCause
();
if
(
cause
instanceof
IOException
)
throw
(
IOException
)
cause
;
if
(
cause
instanceof
ClassNotFoundException
)
throw
(
ClassNotFoundException
)
cause
;
throw
new
AssertionError
(
x
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录