mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-01 03:30:34 +00:00
8130242: DataFlavorComparator transitivity exception
Reviewed-by: alexsch, azvegint
This commit is contained in:
parent
58be04ef9d
commit
adf9cffca5
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 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
|
||||
@ -574,14 +574,7 @@ public class DataFlavorUtil {
|
||||
return comp;
|
||||
}
|
||||
} else {
|
||||
// First, prefer application types.
|
||||
comp = compareIndices(primaryTypes, primaryType1, primaryType2,
|
||||
UNKNOWN_OBJECT_LOSES);
|
||||
if (comp != 0) {
|
||||
return comp;
|
||||
}
|
||||
|
||||
// Next prefer text types
|
||||
// First, prefer text types
|
||||
if (flavor1.isFlavorTextType()) {
|
||||
return 1;
|
||||
}
|
||||
@ -590,6 +583,13 @@ public class DataFlavorUtil {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Next, prefer application types.
|
||||
comp = compareIndices(primaryTypes, primaryType1, primaryType2,
|
||||
UNKNOWN_OBJECT_LOSES);
|
||||
if (comp != 0) {
|
||||
return comp;
|
||||
}
|
||||
|
||||
// Next, look for application/x-java-* types. Prefer unknown
|
||||
// MIME types because if the user provides his own data flavor,
|
||||
// it will likely be the most descriptive one.
|
||||
|
||||
@ -38,42 +38,61 @@ public class DataFlavorComparatorTest1 {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String[] mimes = new String[] {
|
||||
"text/plain;class=java.nio.ByteBuffer;charset=UTF-8",
|
||||
"text/uri-list;class=java.nio.ByteBuffer;charset=UTF-8",
|
||||
"text/plain;class=java.nio.ByteBuffer;charset=UTF-16LE",
|
||||
"text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16LE",
|
||||
"application/x-java-text-encoding",
|
||||
"application/x-java-serialized-object;class=java.lang.String",
|
||||
"text/plain;class=java.io.InputStream;charset=UTF-8",
|
||||
"text/uri-list;class=java.io.InputStream;charset=UTF-8",
|
||||
"text/plain;class=java.io.InputStream;charset=windows-1252",
|
||||
"text/uri-list;class=java.io.InputStream;charset=windows-1252",
|
||||
"application/x-java-url;class=java.net.URL",
|
||||
"text/plain;class=java.io.Reader",
|
||||
"text/plain;charset=windows-1252",
|
||||
"text/uri-list;class=java.io.Reader",
|
||||
"text/uri-list;charset=windows-1252",
|
||||
"text/plain;charset=UTF-8",
|
||||
"text/uri-list;charset=UTF-8",
|
||||
"text/plain;class=java.io.InputStream;charset=US-ASCII",
|
||||
"text/uri-list;class=java.io.InputStream;charset=US-ASCII",
|
||||
"text/plain;class=java.io.InputStream;charset=UTF-16LE",
|
||||
"text/plain;charset=US-ASCII",
|
||||
"text/uri-list;class=java.io.InputStream;charset=UTF-16LE",
|
||||
"text/uri-list;charset=US-ASCII",
|
||||
"text/plain;charset=UTF-16LE",
|
||||
"text/uri-list;charset=UTF-16LE",
|
||||
"text/plain;class=java.nio.ByteBuffer;charset=UTF-16BE",
|
||||
"text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16BE",
|
||||
"text/plain;class=java.nio.ByteBuffer;charset=ISO-8859-1",
|
||||
"text/uri-list;class=java.nio.ByteBuffer;charset=ISO-8859-1",
|
||||
"text/plain",
|
||||
"text/plain; charset=unicode",
|
||||
"text/plain; charset=cp1251",
|
||||
"text/plain; charset=unicode; class=java.io.InputStream",
|
||||
"text/plain; charset=unicode; class=java.io.Serializable",
|
||||
"text/plain; charset=unicode; class=java.lang.Object",
|
||||
"text/plain; class=java.lang.String",
|
||||
"text/plain; class=java.io.Reader",
|
||||
"text/plain; class=java.lang.Object",
|
||||
"text/html",
|
||||
"text/html; charset=unicode",
|
||||
"text/html; charset=cp1251",
|
||||
"text/html; charset=unicode; class=java.io.InputStream",
|
||||
"text/html; charset=unicode; class=java.io.Serializable",
|
||||
"text/html; charset=unicode; class=java.lang.Object",
|
||||
"text/html; class=java.lang.String",
|
||||
"text/html; class=java.io.Reader",
|
||||
"text/html; class=java.lang.Object",
|
||||
"text/unknown",
|
||||
"text/unknown; charset=unicode",
|
||||
"text/unknown; charset=cp1251",
|
||||
"text/unknown; charset=unicode; class=java.io.InputStream",
|
||||
"text/unknown; charset=unicode; class=java.io.Serializable",
|
||||
"text/unknown; charset=unicode; class=java.lang.Object",
|
||||
"text/unknown; class=java.lang.String",
|
||||
"text/unknown; class=java.io.Reader",
|
||||
"text/unknown; class=java.lang.Object",
|
||||
"application/unknown; class=java.io.InputStream",
|
||||
"application/unknown; class=java.lang.Object",
|
||||
"application/unknown",
|
||||
"application/x-java-jvm-local-objectref; class=java.io.InputStream",
|
||||
"application/x-java-jvm-local-objectref; class=java.lang.Object",
|
||||
"application/x-java-jvm-local-objectref",
|
||||
"unknown/flavor",
|
||||
"unknown/flavor; class=java.io.InputStream",
|
||||
"unknown/flavor; class=java.lang.Object",
|
||||
"text/uri-list",
|
||||
"text/plain;class=java.nio.ByteBuffer;charset=UTF-16",
|
||||
"text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16",
|
||||
"text/plain;class=java.io.InputStream;charset=unicode",
|
||||
"text/uri-list;class=java.io.InputStream;charset=UTF-16",
|
||||
"text/plain;class=java.nio.CharBuffer",
|
||||
"text/uri-list;class=java.nio.CharBuffer",
|
||||
"text/plain;class=java.lang.String",
|
||||
"text/plain;charset=UTF-16BE",
|
||||
"text/uri-list;class=java.lang.String",
|
||||
"text/uri-list;charset=UTF-16BE",
|
||||
"text/plain;charset=ISO-8859-1",
|
||||
"text/uri-list;charset=ISO-8859-1",
|
||||
"text/plain;class=java.io.InputStream;charset=UTF-16BE",
|
||||
"text/uri-list;class=java.io.InputStream;charset=UTF-16BE",
|
||||
"text/plain;class=java.nio.ByteBuffer;charset=US-ASCII",
|
||||
"text/uri-list;class=java.nio.ByteBuffer;charset=US-ASCII",
|
||||
"text/plain;class=java.io.InputStream;charset=ISO-8859-1",
|
||||
"text/uri-list;class=java.io.InputStream;charset=ISO-8859-1",
|
||||
"text/plain;charset=UTF-16",
|
||||
"text/plain;class=java.nio.ByteBuffer;charset=windows-1252",
|
||||
"text/uri-list;charset=UTF-16",
|
||||
"text/uri-list;class=java.nio.ByteBuffer;charset=windows-1252",
|
||||
"text/plain;class=java.io.InputStream;charset=windows-1252",
|
||||
"text/uri-list;class=java.io.InputStream;charset=windows-1252",
|
||||
};
|
||||
|
||||
DataFlavor[] flavors = new DataFlavor[mimes.length];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user