Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4932376

IOException on drop part of drag'n'drop

XMLWordPrintable

    • 04
    • generic
    • generic
    • Verified


        We are investigating the following exception which occurs in the drop phase of a D'n'D operation.

        ******************************************************************************

        java.io.IOException: com.nortel.cpt.gui.dnd.TemplateItem
                at sun.awt.datatransfer.TransferableProxy.getTransferData(TransferableProxy
        .java:61)
                at java.awt.dnd.DropTargetContext$TransferableProxy.getTransferData(DropTar
        getContext.java:359)
                at com.nortel.cpt.gui.dnd.DropTree.drop(DropTree.java:270)
                at java.awt.dnd.DropTarget.drop(DropTarget.java:404)
                at sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(SunDropTargetCon
        textPeer.java:547)
                at sun.awt.dnd.SunDropTargetContextPeer.access$800(SunDropTargetContextPeer
        .java:52)
                at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchDropEvent(S
        unDropTargetContextPeer.java:806)
                at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(SunDr
        opTargetContextPeer.java:744)
                at sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTargetEvent.java:29)
                at java.awt.Component.dispatchEventImpl(Component.java:3456)
                at java.awt.Container.dispatchEventImpl(Container.java:1623)
                at java.awt.Component.dispatchEvent(Component.java:3439)
                at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
                at java.awt.LightweightDispatcher.processDropTargetEvent(Container.java:323
        6)
                at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3090)
                at java.awt.Container.dispatchEventImpl(Container.java:1609)
                at java.awt.Window.dispatchEventImpl(Window.java:1585)
                at java.awt.Component.dispatchEvent(Component.java:3439)
                at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
                at com.nortel.inmP.commonuiP.swingP.GUIBlockerC.dispatchEvent(GUIBlockerC.j
        ava:207)
                at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThrea
        d.java:197)
                at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.
        java:150)
                at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
                at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
                at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

        ****************************************************************************

        This exception only occurs when the transfer object "TemplateItem" (and the DataFlavour) are not in the classpath but have been loaded by a user class loader (URLClassLoader). In our environment, most classes are loaded this way - the system and bootstrap loaders are not busy. The problem can be easily seen in the following decompiled code from

        sun.awt.datatransfer.TransferableProxy:

            public Object getTransferData(DataFlavor dataflavor)
                throws UnsupportedFlavorException, IOException
            {
                Object obj = transferable.getTransferData(dataflavor);
                if(obj != null && isLocal &&
        dataflavor.isFlavorSerializedObjectType())
                {
                    ByteArrayOutputStream bytearrayoutputstream = new
        ByteArrayOutputStream();
                    (new
        ObjectOutputStream(bytearrayoutputstream)).writeObject(obj);
                    ByteArrayInputStream bytearrayinputstream = new
        ByteArrayInputStream(bytearrayoutputstream.toByteArray());
                    try
                    {
                        obj = (new
        ObjectInputStream(bytearrayinputstream)).readObject();
                    }
                    catch(ClassNotFoundException classnotfoundexception)
                    {
                        throw new IOException(classnotfoundexception.getMessage());

                    }
                }
                return obj;
            }

        In this method, the transfer object obj is being serialized and deserialized. In the deserialization step, the classloader present in obj or dataflavor is not used (and it should be) to recreate obj. When the classloader in obj is different than the classloader in the ObjectInputStream, this code will not work.

              dassunw Das Das (Inactive)
              gnagasunsunw Gopinath Nagasundara (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: