Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4654688
Votes 0
Synopsis getFlavorsForNative() and getNativesForFlavor() are inconsistent with javadoc
Category java:drag&drop
Reported Against hopper
Release Fixed 1.5(tiger)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs
Submit Date 19-MAR-2002
Description



 xxxxx@xxxxx 

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:
----------------------------------------------------------------------
< xxxxx@xxxxx (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. 
  
 xxxxx@xxxxx  2002-03-19
======================================================================
Work Around




======================================================================
Evaluation
Here is the evaluation by the responsible engineer,  xxxxx@xxxxx 

This bug requires an API change.
The possible solution would be to modify the javadoc for
SystemFlavorMap.getNativesForFlavor() as follows:

--- SystemFlavorMap.java        Fri Mar 15 17:52:12 2002
***************
*** 558,564 ****
       * flavor to the underlying native platform.
       * <p>
       * If the specified <code>DataFlavor</code> is previously unknown to the
!      * data transfer subsystem, then invoking this method will establish a
       * mapping in both directions between the specified <code>DataFlavor</code>
       * and an encoded version of its MIME type as its native.
       *
--- 558,566 ----
       * flavor to the underlying native platform.
       * <p>
       * If the specified <code>DataFlavor</code> is previously unknown to the
!      * data transfer subsystem and this <code>DataFlavor</code> cannot be
!      * translated to any <code>String</code> native currently known to the data
!      * transfer subsystem, then invoking this method will establish a
       * mapping in both directions between the specified <code>DataFlavor</code>
       * and an encoded version of its MIME type as its native. 


 xxxxx@xxxxx  2002-05-01
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang