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

Solaris: Core dumped when dropping from TextField to DropTarget

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2fcs
    • CPU:
      sparc
    • OS:
      solaris_2.6
    • Verification:
      Not verified

      Description

      Please see update at bottom... this bug seems to be visible in C locale also.
      --------
      Run the following program.
      The top TextArea is Drop area.
      The middle TextArea is Drag area.
      The bottom TextArea is normal TextArea.

      DnD from Drop area to Drag area works correctly.
      but, DnD from normal TextArea to Drag area causes SEGV and dumps core
      if the drag source contains Japanese character.
      if the drag source contains only ASCII, it works correctly.

      Also, dropping from CDE/Motif to java apps, if the dropped character is
      non-ascii, no character is dropped.

      -----
      /*
       * Test Program for JDK1.2
       * Copyright Fujitsu Limited 1998
       *
       * Test case for class java.awt.dnd.*
       *
       */

      import java.awt.*;
      import java.awt.dnd.*;
      import java.awt.datatransfer.*;
      import java.awt.event.*;
      import java.io.*;

      public class DragDropTest extends Frame {
      public static int WIDTH = 600;
      public static int HEIGHT = 400;

      private Target target;
      private Source source;

      // Target
      class Target extends TextArea implements DropTargetListener {
      private DropTarget target;

      public Target(String text) {
      super(text);
      this.target = new DropTarget(this, DnDConstants.ACTION_COPY, this);
      this.setDropTarget(target);
      }

      // Interface DropTargetListner
      public void dragEnter(DropTargetDragEvent dtde) {
      System.out.println("[Target]-dragEnter");
      System.out.println(" Source Actions = " + dtde.getSourceActions() );

      DataFlavor df[] = dtde.getCurrentDataFlavors();
      System.out.println(" DataFlavor[] Count = " + df.length );
      for (int i = 0; i < df.length; i++) {
      System.out.println(" MIMEType[" + i + "]=" + df[i].getMimeType() );
      if (df[i].equals(DataFlavor.plainTextFlavor)) {
      // Accept the drag
      System.out.println(" Accept the drag!!");
      dtde.acceptDrag( DnDConstants.ACTION_COPY );
      return;
      }
      }
      // Reject the drag
      System.out.println(" Reject the drag!!");
      dtde.rejectDrag();
      }

      public void dragOver(DropTargetDragEvent dtde) {
      //System.out.println("[Target]-dragOver");
      }

      public void dropActionChanged(DropTargetDragEvent dtde) {
      System.out.println("[Target]-dropActionChanged");
      }

      public void dragScroll(DropTargetDragEvent dtde) {
      System.out.println("[Target]-dragScroll");
      }

      public void dragExit(DropTargetEvent dte) {
      System.out.println("[Target]-dragExit");
      }

      public void drop(DropTargetDropEvent dtde) {
      System.out.println("[Target]-dropped");
      dtde.acceptDrop(DnDConstants.ACTION_COPY);

      Transferable trans = dtde.getTransferable();
      DataFlavor df[] = dtde.getCurrentDataFlavors();
      // DataFlavor df[] = trans.getTransferDataFlavors();
      Object obj = null;

      try {
      for (int i = 0; i < df.length; i++) {
      // System.out.println("df[" + i + "]=" + df[i] );
      System.out.println(" MIMEType[" + i + "]=" + df[i].getMimeType() );
      if (df[i].equals (DataFlavor.plainTextFlavor)) {
      obj = trans.getTransferData(df[i]);
      }
      }
      if (obj == null) {
      throw new Error("Found plainTextFlavor put null value!");
      }
      System.out.println(" obj type is " + obj.getClass());

      if (obj != null && obj instanceof InputStream) {
      InputStream input = (InputStream)obj;
      StringBuffer str = new StringBuffer();
      byte[] buffer = new byte[64];
      int count = input.read(buffer);
      System.out.println("InputStream Read = "+Integer.toString(count));
      while (count != -1) {
      str.append(new String(buffer, 0, count));
      count = input.read(buffer);
      }
      input.close();
      // System.out.println("str is " + str.toString());
      this.setText(str.toString());
      }
      else {
      if ( obj instanceof String ) {
      this.setText((String)obj);
      }
      }
      }
      catch (Exception e) {
      e.printStackTrace();
      }
      finally {
      try {
      target.getDropTargetContext().dropComplete(true);
      }
      catch (Exception ignore){}
      }
      }
      }

      // Source
      class Source extends TextArea implements DragSourceListener, DragGestureListener {
      DragSource source;
      DragGestureRecognizer dgr;
      Image dragImage = null;
      TextData transferable;

      public Source(String text) {
      super(text);
      this.source = new DragSource();
      //this.dgr = source.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, this);
      this.dgr = new MyMouseDragGestureRecognizer(this.source, this, DnDConstants.ACTION_COPY, this);
      this.transferable = new TextData(this);
      // this.dragImage = ???;
      //this.addMouseListener(new Mouse(this));
      }

      /*
      * TextData
      */
      public class TextData implements Transferable {
      TextComponent text;

      public TextData(TextComponent text) {
      this.text = text;
      }

      // Interface Transferable
      public DataFlavor[] getTransferDataFlavors() {
      DataFlavor[] flavors = new DataFlavor[1];
      flavors[0] = DataFlavor.plainTextFlavor;
      return flavors;
      }

      public boolean isDataFlavorSupported(DataFlavor flavor) {
      return (flavor.equals(DataFlavor.plainTextFlavor));
      }

      public Object getTransferData(DataFlavor flavor)
      throws UnsupportedFlavorException, IOException {
      // return text.getSelectedText();
      return text.getText();
      }
      }

      /*
      * MyMouseDragGestureRecognizer
      */
      class MyMouseDragGestureRecognizer extends MouseDragGestureRecognizer {
      public MyMouseDragGestureRecognizer(DragSource ds, Component c, int actions, DragGestureListener dgl) {
      super(ds, c, actions, dgl);
      }

      public void mousePressed(MouseEvent e) {
      //System.out.println("mousePressed");
      appendEvent(e);
      fireDragGestureRecognized(DnDConstants.ACTION_COPY, e.getPoint());
      }
      }

      /*
      * Mouse
      */
      /* public class Mouse extends MouseAdapter {
      protected Source source;

      public Mouse(Source s) {
      super();
      this.source = s;
      }

      public void mousePressed(MouseEvent e) {
      //if (source.getSelectionStart() != source.getSelectionEnd()) {
      DragGestureEvent dge = new DragGestureEvent(source.dgr, DnDConstants.ACTION_COPY, new Point(0,0), e);
      source.source.startDrag(dge,
      DragSource.DefaultCopyDrop,
      source.dragImage,
      new Point(0,0),
      source.transferable,
      source);
      //}
      }
      }*/

      // Interface DragSourceListener
      public void dragEnter(DragSourceDragEvent dsde) {
      //System.out.println("[Source]-dragEnter");
      }
      public void dragOver(DragSourceDragEvent dsde) {
      //System.out.println("[Source]-dragOver");
      }
      public void dropActionChanged(DragSourceDragEvent dsde) {
      //System.out.println("[Source]-dropActionChanged");
      }
      public void dragGestureChanged(DragSourceDragEvent dsde) {
      //System.out.println("[Source]-dragGestureChanged");
      }
      public void dragExit(DragSourceEvent dse) {
      //System.out.println("[Source]-dragExit");
      }
      public void dragDropEnd(DragSourceDropEvent dsde) {
      //System.out.println("[Source]-dragDropEnd");
      }

      // Interface DragGestureListener
      public void dragGestureRecognized(DragGestureEvent dge) {
      System.out.println("[Source]-dragGestureRecognized");
      source.startDrag(dge,
      DragSource.DefaultCopyDrop,
      dragImage,
      new Point(0,0),
      transferable,
      this);
      }
      }

      public DragDropTest() {
      super("Drag and Drop Test");
      this.setLayout(new GridLayout(3, 1));
      this.target = new Target("\uff24\uff52\uff4f\uff50\u30a8\u30ea\u30a2\npull it over here!");
      this.add(target);
      this.source = new Source("\uff24\uff52\uff41\uff47\u30a8\u30ea\u30a2\nput me over there!");
      this.add(source);
      this.add(new TextArea("\u305f\u3060\u306e\u30c6\u30ad\u30b9\u30c8\u30a8\u30ea\u30a2\n\uff9c\uff70\uff84\uff9e\uff8a\uff9f\uff6f\uff84\uff9e/\uff74\uff78\uff7d\uff8c\uff9f\uff9b\uff70\uff97\u304b\u3089"));
      enableEvents(AWTEvent.WINDOW_EVENT_MASK);
      }

      public static void main(String args[]){
      DragDropTest f = new DragDropTest();
      f.setSize(WIDTH, HEIGHT);
      f.setVisible(true);
      }

      protected void processWindowEvent(WindowEvent e) {
      if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
      }
      super.processWindowEvent(e);
      }
      }

      UPDATE:

      This bug, or one with same manifestation, occurs on SOlaris 2.6/JDK-FCSK in C locale. Test case (provided in Comments section) is a simple variant of program used to test DnD in-house. Core dump occurs when dragging from ordinary text field (via highlighting of text followed by drag) to onto DropSource.

      See Comments for stack info...
      bill.haneman@ireland 1998-09-25

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lcablesunw Larry Cable (Inactive)
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: