United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4654688 : getFlavorsForNative() and getNativesForFlavor() are inconsistent with javadoc

Details
Type:
Bug
Submit Date:
2002-03-19
Status:
Resolved
Updated Date:
2003-08-19
Project Name:
JDK
Resolved Date:
2003-08-19
Component:
client-libs
OS:
generic
Sub-Component:
java.awt
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.1
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

Description

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
======================================================================

                                    

Comments
EVALUATION

Here is the evaluation by the responsible engineer, ###@###.###

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. 


###@###.### 2002-05-01
                                     
2002-05-01
WORK AROUND



Name: dsR10078			Date: 03/19/2002


======================================================================
                                     
2004-06-11
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b16


                                     
2004-06-14



Hardware and Software, Engineered to Work Together