classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] RFC: ChannelReader #1


From: Andrew John Hughes
Subject: Re: [cp-patches] RFC: ChannelReader #1
Date: Mon, 31 Jan 2005 11:11:39 +0000

On Mon, 2005-01-31 at 04:51 +0100, Robert Schuster wrote:
> Hi,
> this patch brings support for the 1.4 style constructors of 
> InputStreamReader. These are the ones that take an InputStream and a 
> java.nio.charset.Charset[Decoder]. The implementation is easy and 
> depends on the Channels class
> which has allows to wrap IO-style classes in NIO-style classes.
> 

Thanks for doing this.  The lack of the InputStream{Reader,Writer}
constructors is the only thing keeping Classpath from running findbugs
at present (I temporarily hacked the constructors to just use the name
from the Charset, and have had successful runs of findbugs since).

> However Channels had only a stub implementation for 
> newReader(ReadableByteChannel, CharsetDecoder). I changed that by 
> writing the adapter: gnu.java.nio.ChannelReader .
> 

Which isn't included in the patch :(  It's not just me then.

> The quirk for having the new InputStreamReader constructors isn't that 
> interesting. The real value of the ChannelReader is that we can now 
> start porting our own character decoders (gnu.java.io.decoder) to NIO.
> 
> Dalibor said that Kaffe has a NIO Charset thats based on iconv. With the 
> ChannelReader we can use that from IO, too.
> 
> However. This is only the first version of the patch. Its here for 
> general review. I need to look for corner-cases and exception behavior 
> and polish it up every here and then.
> 
One thing that occurred to me from looking at the patch (without the
class, I couldn't compile).  If you remove the decoder instance
(replacing it with Reader), how do the other constructors and the rest
of the class still operate?

     this.in = EncodingManager.getDecoder(in, encoding_name);
   }
 
+  public InputStreamReader(InputStream in, Charset charset) {
+    this.in = Channels.newReader(Channels.newChannel(in),
charset.newDecoder(), -1);

in is declared to be of type Reader.  Is this a superclass of the
Decoder class, as that's the only way I can see the first line still
working?  Sorry if I've missed something; as I say, I can't see the new
class or compile at present.

> After that I am going to implement ChannelReader's counterpart: The evil 
> ChannelWriter ... if no else is faster :-)
> 
> The Changelog for the patch will look like this:
> 2005-01-31  Robert Schuster  <address@hidden>
> 
>         * java/nio/channels/Channels: Added FIXMEs for
>         stub method implementation.
>         (newReader): Implemented.
>         * java/io/InputStreamReader:
>         (InputStreamReader(InputStream, Charset)): Implemented.
>         (InputStreamReader(InputStream, CharsetDecoder)): Implemented.
>         * gnu/java/nio/ChannelReader: New class.
> 
> Btw: 
> http://developer.classpath.org/mediation/ClasspathCurrentTopics#head-29147ec4a694664ae99b73085a0922c613f39d64
> 
> Has some more details about GNU Classpath's character conversion 
> frameworks and their problems.
> 
> cu
> Robert
> _______________________________________________
> Classpath-patches mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/classpath-patches

Great work.  Thanks again,
-- 
Andrew :-)

Please avoid sending me Microsoft Office (e.g. Word, PowerPoint)
attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html

No software patents in Europe -- http://nosoftwarepatents.com

"Value your freedom, or you will lose it, teaches history. 
`Don't bother us with politics' respond those who don't want to learn." 
-- Richard Stallman

"We've all been part of the biggest beta test the world has ever known
--
Windows" 
-- Victor Wheatman, Gartner


Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]