Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
86730620
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看板
提交
86730620
编写于
8月 14, 2013
作者:
P
pchelko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7173464: Clipboard.getAvailableDataFlavors: Comparison method violates contract
Reviewed-by: anthony, art, serb
上级
3c4d1283
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
50 deletion
+52
-50
src/share/classes/sun/awt/datatransfer/ClipboardTransferable.java
...e/classes/sun/awt/datatransfer/ClipboardTransferable.java
+1
-2
src/share/classes/sun/awt/datatransfer/DataTransferer.java
src/share/classes/sun/awt/datatransfer/DataTransferer.java
+4
-48
test/sun/awt/datatransfer/DataFlavorComparatorTest.java
test/sun/awt/datatransfer/DataFlavorComparatorTest.java
+47
-0
未找到文件。
src/share/classes/sun/awt/datatransfer/ClipboardTransferable.java
浏览文件 @
86730620
...
...
@@ -98,8 +98,7 @@ public class ClipboardTransferable implements Transferable {
}
flavors
=
DataTransferer
.
getInstance
().
setToSortedDataFlavorArray
(
flavorsToData
.
keySet
(),
flavorsForFormats
);
setToSortedDataFlavorArray
(
flavorsToData
.
keySet
());
}
}
finally
{
clipboard
.
closeClipboard
();
...
...
src/share/classes/sun/awt/datatransfer/DataTransferer.java
浏览文件 @
86730620
...
...
@@ -2405,15 +2405,6 @@ search:
return
retval
;
}
/**
* Helper function to reduce a Map with DataFlavor keys to a DataFlavor
* array. The array will be sorted according to
* <code>DataFlavorComparator</code>.
*/
public
static
DataFlavor
[]
keysToDataFlavorArray
(
Map
map
)
{
return
setToSortedDataFlavorArray
(
map
.
keySet
(),
map
);
}
/**
* Helper function to convert a Set of DataFlavors to a sorted array.
* The array will be sorted according to <code>DataFlavorComparator</code>.
...
...
@@ -2427,24 +2418,6 @@ search:
return
flavors
;
}
/**
* Helper function to convert a Set of DataFlavors to a sorted array.
* The array will be sorted according to a
* <code>DataFlavorComparator</code> created with the specified
* flavor-to-native map as an argument.
*/
public
static
DataFlavor
[]
setToSortedDataFlavorArray
(
Set
flavorsSet
,
Map
flavorToNativeMap
)
{
DataFlavor
[]
flavors
=
new
DataFlavor
[
flavorsSet
.
size
()];
flavorsSet
.
toArray
(
flavors
);
Comparator
comparator
=
new
DataFlavorComparator
(
flavorToNativeMap
,
IndexedComparator
.
SELECT_WORST
);
Arrays
.
sort
(
flavors
,
comparator
);
return
flavors
;
}
/**
* Helper function to convert an InputStream to a byte[] array.
*/
...
...
@@ -2724,11 +2697,9 @@ search:
* application/x-java-* MIME types. Unknown application types are preferred
* because if the user provides his own data flavor, it will likely be the
* most descriptive one. For flavors which are otherwise equal, the
* flavors' native formats are compared, with greater long values
* taking precedence.
* flavors' string representation are compared in the alphabetical order.
*/
public
static
class
DataFlavorComparator
extends
IndexedComparator
{
protected
final
Map
flavorToFormatMap
;
private
final
CharsetComparator
charsetComparator
;
...
...
@@ -2864,20 +2835,6 @@ search:
super
(
order
);
charsetComparator
=
new
CharsetComparator
(
order
);
flavorToFormatMap
=
Collections
.
EMPTY_MAP
;
}
public
DataFlavorComparator
(
Map
map
)
{
this
(
map
,
SELECT_BEST
);
}
public
DataFlavorComparator
(
Map
map
,
boolean
order
)
{
super
(
order
);
charsetComparator
=
new
CharsetComparator
(
order
);
HashMap
hashMap
=
new
HashMap
(
map
.
size
());
hashMap
.
putAll
(
map
);
flavorToFormatMap
=
Collections
.
unmodifiableMap
(
hashMap
);
}
public
int
compare
(
Object
obj1
,
Object
obj2
)
{
...
...
@@ -2973,10 +2930,9 @@ search:
}
}
// As a last resort, take the DataFlavor with the greater integer
// format.
return
compareLongs
(
flavorToFormatMap
,
flavor1
,
flavor2
,
UNKNOWN_OBJECT_LOSES_L
);
// The flavours are not equal but still not distinguishable.
// Compare String representations in alphabetical order
return
flavor1
.
getMimeType
().
compareTo
(
flavor2
.
getMimeType
());
}
}
...
...
test/sun/awt/datatransfer/DataFlavorComparatorTest.java
0 → 100644
浏览文件 @
86730620
/*
* Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 7173464
@summary Clipboard.getAvailableDataFlavors: Comparison method violates contract
@author Petr Pchelko
@run main DataFlavorComparatorTest
*/
import
sun.awt.datatransfer.DataTransferer
;
import
java.awt.datatransfer.DataFlavor
;
public
class
DataFlavorComparatorTest
{
public
static
void
main
(
String
[]
args
)
{
DataTransferer
.
DataFlavorComparator
comparator
=
new
DataTransferer
.
DataFlavorComparator
();
DataFlavor
flavor1
=
DataFlavor
.
imageFlavor
;
DataFlavor
flavor2
=
DataFlavor
.
selectionHtmlFlavor
;
if
(
comparator
.
compare
(
flavor1
,
flavor2
)
==
0
)
{
throw
new
RuntimeException
(
flavor1
.
getMimeType
()
+
" and "
+
flavor2
.
getMimeType
()
+
" should not be equal"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录