This is the mail archive of the mailing list for the Java project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix for 'paste'

Tom Tromey wrote:

I looked here:

That's where the bit about Reader and the inconsistency with the
definition of plainTextFlavor comes from.

Thanks. Now I see the inconsistency. What a big spec screw-up.

If the test suite works ok, though, then perhaps the URL above is
incorrect and Sun really does return an InputStream.  In which case
the patch is fine, thanks.  It might be helpful to have a comment
explaining the situation, up to you.

Sorry Tom, the test I was fixing was for a stringFlavor.

I was able to verify that the Sun SDK indeed returns a,
not a

You said: "I forgot to mention: the best thing in a case like this, where the
docs are confusing, is to try it out on the Sun JDK and see what

This seem to imply that we should, in these cases, do as Sun does, right? I've made the change to return StringReader.

Here is the patch that I am checking in. I've added a comment like you suggested.

Thanks for spotting this.

Index: java/awt/datatransfer/
RCS file: /cvs/gcc/gcc/libjava/java/awt/datatransfer/,v
retrieving revision 1.2
diff -c -p -u -r1.2
--- java/awt/datatransfer/	24 Jun 2003 10:50:21 -0000	1.2
+++ java/awt/datatransfer/	8 Dec 2003 23:52:01 -0000
@@ -38,7 +38,7 @@ exception statement from your version. *
 package java.awt.datatransfer;
@@ -140,7 +140,15 @@ getTransferData(DataFlavor flavor) throw
   if (!isDataFlavorSupported(flavor))
     throw new UnsupportedFlavorException(flavor);
-  return(new StringBufferInputStream(data));
+  if (DataFlavor.plainTextFlavor == flavor)
+      /* The behavior of this method for DataFlavor.plainTextFlavor and
+         equivalent DataFlavors is inconsistent with the definition of
+         DataFlavor.plainTextFlavor. We choose to do like Sun's implementation
+         and return a Reader instead of an InputString. */
+      /* return(new StringBufferInputStream(data)); */
+      return(new StringReader(data));
+  else // DataFlavor.stringFlavor
+      return data;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]