5098433: REG: DnD of File-List between JVM is broken for non ASCII file names - Win32
authordenis
Tue, 24 Nov 2009 18:46:17 +0300
changeset 4362 ad915ad8792f
parent 4361 66c14524f39c
child 4363 212067ed03e4
5098433: REG: DnD of File-List between JVM is broken for non ASCII file names - Win32 Reviewed-by: uta, dav
jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java
jdk/src/windows/native/sun/windows/awt_DnDDS.cpp
jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/AbsoluteComponentCenterCalculator.java
jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/DragUnicodeBetweenJVMTest.html
jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/DragUnicodeBetweenJVMTest.java
jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/FileListTransferable.java
jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/InterprocessMessages.java
jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/NextFramePositionCalculator.java
jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/SourcePanel.java
jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/TargetPanel.java
--- a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Fri Nov 20 19:11:47 2009 +0300
+++ b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Tue Nov 24 18:46:17 2009 +0300
@@ -203,6 +203,8 @@
     private static final Map nativeEOLNs =
         Collections.synchronizedMap(new HashMap());
 
+    private static final byte [] UNICODE_NULL_TERMINATOR =  new byte [] {0,0};
+
     /**
      * The number of terminating NUL bytes for the Set of textNatives.
      */
@@ -1299,7 +1301,7 @@
             }
             final List list = (List)obj;
 
-            final ArrayList fileList = new ArrayList();
+            final ArrayList <String> fileList = new ArrayList<String>();
 
             final ProtectionDomain userProtectionDomain = getUserProtectionDomain(contents);
 
@@ -1331,13 +1333,24 @@
                 throw new IOException(pae.getMessage());
             }
 
-            for (int i = 0; i < fileList.size(); i++)
-            {
-                byte[] bytes = ((String)fileList.get(i)).getBytes();
-                if (i != 0) bos.write(0);
-                bos.write(bytes, 0, bytes.length);
+            if(fileList.isEmpty()) {
+                //store empty unicode string (null terminator)
+                bos.write(UNICODE_NULL_TERMINATOR);
+            } else {
+                for (int i = 0; i < fileList.size(); i++) {
+                    byte[] bytes = fileList.get(i).getBytes(getDefaultUnicodeEncoding());
+                    //store unicode string with null terminator
+                    bos.write(bytes, 0, bytes.length);
+                    bos.write(UNICODE_NULL_TERMINATOR);
+                }
             }
 
+            // According to MSDN the byte array have to be double NULL-terminated.
+            // The array contains Unicode characters, so each NULL-terminator is
+            // a pair of bytes
+
+            bos.write(UNICODE_NULL_TERMINATOR);
+
         // Source data is an InputStream. For arbitrary flavors, just grab the
         // bytes and dump them into a byte array. For text flavors, decode back
         // to a String and recur to reencode according to the requested format.
--- a/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp	Fri Nov 20 19:11:47 2009 +0300
+++ b/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp	Tue Nov 24 18:46:17 2009 +0300
@@ -648,7 +648,7 @@
             dropfiles->pt.x = m_dropPoint.x;
             dropfiles->pt.y = m_dropPoint.y;
             dropfiles->fNC = m_fNC;
-            dropfiles->fWide = FALSE; // good guess!
+            dropfiles->fWide = TRUE; // good guess!
             dataout += sizeof(DROPFILES);
         }
 
@@ -815,7 +815,7 @@
             dropfiles->pt.x = m_dropPoint.x;
             dropfiles->pt.y = m_dropPoint.y;
             dropfiles->fNC = m_fNC;
-            dropfiles->fWide = FALSE; // good guess!
+            dropfiles->fWide = TRUE; // good guess!
             dataout += sizeof(DROPFILES);
         }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/AbsoluteComponentCenterCalculator.java	Tue Nov 24 18:46:17 2009 +0300
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.awt.*;
+
+class AbsoluteComponentCenterCalculator {
+    private AbsoluteComponentCenterCalculator () {}
+    public static int calculateXCenterCoordinate(Component component) {
+        return (int)component.getLocationOnScreen().getX()+(component.getWidth()/2);
+    }
+    public static int calculateYCenterCoordinate(Component component) {
+        return (int)component.getLocationOnScreen().getY()+(component.getHeight()/2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/DragUnicodeBetweenJVMTest.html	Tue Nov 24 18:46:17 2009 +0300
@@ -0,0 +1,25 @@
+<html>
+<!--  
+  @test
+  @bug 5098433
+  @summary REG: DnD of File-List between JVM is broken for non ASCII file names - Win32
+  @author Denis Fokin: area=dnd
+  @library ../../regtesthelpers
+  @library ../../regtesthelpers/process
+  @build Util
+  @build ProcessResults ProcessCommunicator 
+  @run applet/othervm DragUnicodeBetweenJVMTest.html
+
+-->
+<head>
+<title> REG: DnD of File-List between JVM is broken for non ASCII file names - Win32</title>
+</head>
+<body>
+
+<h1> DragUnicodeBetweenJVMTest <br>Bug ID: 5098433 </h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="DragUnicodeBetweenJVMTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/DragUnicodeBetweenJVMTest.java	Tue Nov 24 18:46:17 2009 +0300
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+  test
+  @bug 5098433
+  @summary REG: DnD of File-List between JVM is broken for non ASCII file names - Win32
+  @author Denis Fokin: area=dnd
+  @library    ../../regtesthelpers
+  @library ../../regtesthelpers/process
+  @build Util
+  @build ProcessResults ProcessCommunicator
+
+
+  @run applet/othervm DragUnicodeBetweenJVMTest.html
+*/
+
+/**
+ * DragUnicodeBetweenJVMTest.java
+ *
+ * summary: The test drags a list of files (DataFlavor.javaFileListFlavor) from one jvm to another.
+ *          The files have Unicode names. The list on target side must be equal to
+ *          the list on the source side.
+ */
+
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+
+import test.java.awt.regtesthelpers.process.ProcessCommunicator;
+import test.java.awt.regtesthelpers.process.ProcessResults;
+import test.java.awt.regtesthelpers.Util;
+import static java.lang.Thread.sleep;
+
+public class DragUnicodeBetweenJVMTest extends Applet
+{
+
+    public void init() {
+        setLayout(new BorderLayout());
+    }//End  init()
+
+    public void start() {
+
+        String toolkit = Toolkit.getDefaultToolkit().getClass().getName();
+        if (!toolkit.equals("sun.awt.windows.WToolkit")){
+            System.out.println("This test is for Windows only. Passed.");
+            return;
+        }
+        else{
+            System.out.println("Toolkit = " + toolkit);
+        }
+
+        final Frame sourceFrame = new Frame("Source frame");
+        final SourcePanel sourcePanel = new SourcePanel();
+        sourceFrame.add(sourcePanel);
+        sourceFrame.pack();
+        sourceFrame.addWindowListener( new WindowAdapter() {
+            @Override
+            public void windowClosing(WindowEvent e) {
+                sourceFrame.dispose();
+            }
+        });
+        sourceFrame.setVisible(true);
+
+        Util.waitForIdle(null);
+
+        NextFramePositionCalculator positionCalculator = new NextFramePositionCalculator(sourceFrame);
+
+        String [] args = new String [] {
+                String.valueOf(positionCalculator.getNextLocationX()),
+                String.valueOf(positionCalculator.getNextLocationY()),
+                String.valueOf(AbsoluteComponentCenterCalculator.calculateXCenterCoordinate(sourcePanel)),
+                String.valueOf(AbsoluteComponentCenterCalculator.calculateYCenterCoordinate(sourcePanel)),
+        };
+
+
+       ProcessResults processResults =
+                // ProcessCommunicator.executeChildProcess(this.getClass()," -cp \"C:\\Documents and Settings\\df153228\\IdeaProjects\\UnicodeTestDebug\\out\\production\\UnicodeTestDebug\" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 ", args);
+                ProcessCommunicator.executeChildProcess(this.getClass(), args);
+
+        verifyTestResults(processResults);
+
+    }// start()
+
+
+
+    private static void verifyTestResults(ProcessResults processResults) {
+        if ( InterprocessMessages.FILES_ON_TARGET_ARE_CORRUPTED ==
+                processResults.getExitValue())
+        {
+            processResults.printProcessErrorOutput(System.err);
+            throw new RuntimeException("TEST IS FAILED: Target has recieved" +
+                    " broken file list.");
+        }
+        processResults.verifyStdErr(System.err);
+        processResults.verifyProcessExitValue(System.err);
+        processResults.printProcessStandartOutput(System.out);
+    }
+
+    //We cannot make an instance of the applet without the default constructor
+    public DragUnicodeBetweenJVMTest () {
+        super();
+    }
+
+    //We need in this constructor to pass frame position between JVMs
+    public DragUnicodeBetweenJVMTest (Point targetFrameLocation, Point dragSourcePoint)
+            throws InterruptedException
+    {
+        final Frame targetFrame = new Frame("Target frame");
+        final TargetPanel targetPanel = new TargetPanel(targetFrame);
+        targetFrame.add(targetPanel);
+        targetFrame.addWindowListener( new WindowAdapter() {
+            @Override
+            public void windowClosing(WindowEvent e) {
+                targetFrame.dispose();
+            }
+        });
+        targetFrame.setLocation(targetFrameLocation);
+        targetFrame.pack();
+        targetFrame.setVisible(true);
+
+        doTest(dragSourcePoint, targetPanel);
+    }
+
+    private void doTest(Point dragSourcePoint, TargetPanel targetPanel) {
+        Util.waitForIdle(null);
+
+        final Robot robot = Util.createRobot();
+
+        robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY());
+        try {
+            sleep(100);
+            robot.mousePress(InputEvent.BUTTON1_MASK);
+            sleep(100);
+            robot.mouseRelease(InputEvent.BUTTON1_MASK);
+            sleep(100);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+
+        Util.drag(robot, dragSourcePoint, new Point (AbsoluteComponentCenterCalculator.calculateXCenterCoordinate(targetPanel),
+                AbsoluteComponentCenterCalculator.calculateYCenterCoordinate(targetPanel)),
+                InputEvent.BUTTON1_MASK);
+    }
+
+
+    enum InterprocessArguments {
+        TARGET_FRAME_X_POSITION_ARGUMENT,
+        TARGET_FRAME_Y_POSITION_ARGUMENT,
+        DRAG_SOURCE_POINT_X_ARGUMENT,
+        DRAG_SOURCE_POINT_Y_ARGUMENT;
+
+        int extract (String [] args) {
+            return Integer.parseInt(args[this.ordinal()]);
+        }
+    }
+
+    public static void main (String [] args) {
+        Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args),
+                InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args));
+        Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args),
+                InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args));
+
+        try {
+            new DragUnicodeBetweenJVMTest(targetFrameLocation, dragSourcePoint);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/FileListTransferable.java	Tue Nov 24 18:46:17 2009 +0300
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+class FileListTransferable implements Transferable {
+
+    public static File [] files = new File [] {
+        new File ("\u042f\u0020\u0441\u0440\u0430\u0437\u0443\u0020\u0441\u043c\u0430\u0437\u0430\u043b" +
+                "\u0020\u043a\u0430\u0440\u0442\u0443\u0020\u0431\u0443\u0434\u043d\u044f"),
+        new File ("\u043f\u043b\u0435\u0441\u043d\u0443\u0432\u0448\u0438\u0020\u043a\u0440\u0430\u0441" +
+                "\u043a\u0443\u0020\u0438\u0437\u0020\u0441\u0442\u0430\u043a\u0430\u043d\u0430"),
+        new File ("\u044f\u0020\u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0020\u043d\u0430\u0020\u0431" +
+                "\u043b\u044e\u0434\u0435\u0020\u0441\u0442\u0443\u0434\u043d\u044f"),
+        new File ("\u043a\u043e\u0441\u044b\u0435\u0020\u0441\u043a\u0443\u043b\u044b\u0020\u043e\u043a" +
+                "\u0435\u0430\u043d\u0430"),
+        new File ("\u041d\u0430\u0020\u0447\u0435\u0448\u0443\u0435\u0020\u0436\u0435\u0441\u0442\u044f" +
+                "\u043d\u043e\u0439\u0020\u0440\u044b\u0431\u044b"),
+        new File ("\u043f\u0440\u043e\u0447\u0435\u043b\u0020\u044f\u0020\u0437\u043e\u0432\u044b\u0020" +
+                "\u043d\u043e\u0432\u044b\u0445\u0020\u0433\u0443\u0431"),
+        new File ("\u0410\u0020\u0432\u044b"),
+        new File ("\u043d\u043e\u043a\u0442\u044e\u0440\u043d\u0020\u0441\u044b\u0433\u0440\u0430\u0442" +
+                "\u044c"),
+        new File ("\u043c\u043e\u0433\u043b\u0438\u0020\u0431\u044b"),
+        new File ("\u043d\u0430\u0020\u0444\u043b\u0435\u0439\u0442\u0435\u0020\u0432\u043e\u0434\u043e" +
+                "\u0441\u0442\u043e\u0447\u043d\u044b\u0445\u0020\u0442\u0440\u0443\u0431"),
+    };
+
+    public DataFlavor[] getTransferDataFlavors() {
+        return new DataFlavor [] {DataFlavor.javaFileListFlavor};
+    }
+
+    public boolean isDataFlavorSupported(DataFlavor flavor) {
+        return flavor.equals(DataFlavor.javaFileListFlavor) ;
+    }
+
+    public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
+        List<File> list = Arrays.asList(files);
+        return list;
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/InterprocessMessages.java	Tue Nov 24 18:46:17 2009 +0300
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+interface InterprocessMessages {
+    final static int EXECUTION_IS_SUCCESSFULL = 0;
+    final static int FILES_ON_TARGET_ARE_CORRUPTED = 212;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/NextFramePositionCalculator.java	Tue Nov 24 18:46:17 2009 +0300
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.awt.*;
+
+
+class NextFramePositionCalculator {
+
+    private final Frame currentFrame;
+
+    public NextFramePositionCalculator (Frame currentFrame) {
+        this.currentFrame = currentFrame;
+    }
+
+    public int getNextLocationX() {
+        return currentFrame.getX()+currentFrame.getWidth();
+    }
+
+    public int getNextLocationY() {
+        return currentFrame.getY();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/SourcePanel.java	Tue Nov 24 18:46:17 2009 +0300
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.*;
+
+public class SourcePanel extends Panel
+{
+
+    private final MyDragGestureListener dragGestureListener =
+            new MyDragGestureListener();
+
+    public SourcePanel () {
+        setPreferredSize(new Dimension(200, 200));
+        DragSource defaultDragSource =
+                DragSource.getDefaultDragSource();
+        defaultDragSource.createDefaultDragGestureRecognizer(this,
+                DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
+        setBackground(Color.RED);
+    }
+
+    private class MyDragGestureListener implements DragGestureListener {
+        public void dragGestureRecognized(DragGestureEvent dge) {
+            dge.startDrag(null, new FileListTransferable());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/datatransfer/DragUnicodeBetweenJVMTest/TargetPanel.java	Tue Nov 24 18:46:17 2009 +0300
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.awt.dnd.*;
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Arrays;
+
+public class TargetPanel extends Panel implements DropTargetListener{
+
+    private java.util.List <File> content = new ArrayList<File>();
+
+    //private final CustomDropTargetListener dropTargetListener = new CustomDropTargetListener();
+
+    private Frame frame;
+
+    public TargetPanel (Frame frame)
+    {
+        this.frame = frame;
+        setBackground(Color.DARK_GRAY);
+        setPreferredSize(new Dimension(200, 200));
+        setDropTarget(new DropTarget(this, this));
+    }
+
+    public void dragEnter(DropTargetDragEvent dtde) {
+        if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
+            dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
+        }
+    }
+
+    public void dragOver(DropTargetDragEvent dtde) {
+        if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
+            dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
+        }
+    }
+
+    public void dropActionChanged(DropTargetDragEvent dtde) {
+        if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
+            dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
+        }
+    }
+
+    public void dragExit(DropTargetEvent dte) {
+
+    }
+
+    public void drop(DropTargetDropEvent dtde) {
+        dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
+        if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
+            try {
+                content = (java.util.List)dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
+                repaint();
+            } catch (UnsupportedFlavorException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            dtde.dropComplete(true);
+
+
+
+            boolean listsAreEqual = true;
+
+             for (int i = 0; i < content.size(); i++) {
+                if(!FileListTransferable.files[i].getName().equals(content.get(i).getName())) {
+                    listsAreEqual = false;
+                }
+            }
+
+            if (listsAreEqual) {
+                System.err.println(InterprocessMessages.EXECUTION_IS_SUCCESSFULL);
+                System.exit(0);
+            }
+        }
+        dtde.rejectDrop();
+        System.err.println(InterprocessMessages.FILES_ON_TARGET_ARE_CORRUPTED);
+        System.exit(1);
+    }
+
+    public void paint(Graphics g) {
+        g.setColor(Color.YELLOW);
+        int i = 0;
+        for (Iterator <File> iterator = content.iterator(); iterator.hasNext();i++) {
+            g.drawString(iterator.next().getName(), 5, g.getFontMetrics().getAscent()*i+20);
+        }
+
+    }
+
+}