Name: dsR10078 Date: 03/19/2002
###@###.###
The following test case reproduces the problem:
----------------------------------------------------------------------
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.SystemFlavorMap;
import java.util.List;
public class Test {
public static void main(String[] args) {
DataFlavor flavor = new DataFlavor("text/plain", "Test DataFlavor");
SystemFlavorMap flavorMap =
(SystemFlavorMap)SystemFlavorMap.getDefaultFlavorMap();
List knownFlavors = flavorMap.getFlavorsForNative(null);
System.out.println("Is " + flavor + " known : " +
knownFlavors.contains(flavor));
System.out.println("Natives for " + flavor + " : " +
flavorMap.getNativesForFlavor(flavor));
}
}
----------------------------------------------------------------------
Compile and run the test case.
On Win32 the output is as follows:
----------------------------------------------------------------------
Z:\new_bug>J:\JDK1.4.1-b05\win32\bin\java Test
Is java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=Cp1252] known : false
Natives for java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=Cp1252] : [UNICODE TEXT, TEXT, UniformResourceLocator]
----------------------------------------------------------------------
On Solaris/Linux the output is as follows:
----------------------------------------------------------------------
<das@libox(pts/29).270> /net/archer/jdk-builds/JDK1.4.1-b05/linux/bin/java Test
Is java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=ISO8859_1] known : false
Natives for java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=ISO8859_1] : [COMPOUND_TEXT, TEXT, STRING]
----------------------------------------------------------------------
SystemFlavorMap.getFlavorsForNative(null) is documented to return
"all DataFlavors currently known to the data transfer subsystem".
The javadoc for getNativesForFlavor() specifies that "if the
specified DataFlavor is previously unknown to the data transfer
subsystem, then invoking this method will establish a mapping in
both directions between the specified DataFlavor and an encoded
version of its MIME type as its native".
In the example above, the created data flavor is not contained in the
List, returned from SystemFlavorMap.getFlavorsForNative(null), so it
is unknown to the data transfer subsystem, but on all platforms
getNativesForFlavor() for this data flavor returns three natives, none
of them is the encoded version of its MIME type.
This inconsistency exists since this API first appeared in 1.4.0.
###@###.### 2002-03-19
======================================================================