Hi Gary, David Daney made a good point that reminded me that it probably wasn't as clever as I thought to extend the FilterOutputStream, so extend OutputStream and implementing all methods would be a better idea. I also liked David's suggestion of making this a reusable utility class in gnu.java.io.*.
(and just to be complete, I agree with the others that the exception text should be changed as well.) Regards, Jeroen > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > On Behalf Of Gary Benson > Sent: Thursday, December 08, 2005 17:25 > To: [email protected] > Subject: Re: [cp-patches] FYI: Opening > RandomAccessFilesrequiresexcessivepermission > > Hi Jeroen, > > Oh, in that case I'll use your patch, assuming nobody objects. > The mauve test ought to spot anything that slips through. > > Cheers, > Gary > > Jeroen Frijters wrote: > > Hi Gary, > > > > I used a FilterOutputStream because that funnels all writes into the > > write(int b) method, so you'd only have to override that single > > method. > > > > Personally I wouldn't really like a solution based on > > FileChannelImpl, but that's simply because IKVM uses a modified > > version FileChannelImpl. > > > > Regards, > > Jeroen > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] > > > On Behalf Of Gary Benson > > > Sent: Thursday, December 08, 2005 13:02 > > > To: [email protected] > > > Subject: Re: [cp-patches] FYI: Opening RandomAccessFiles > > > requiresexcessivepermission > > > > > > Hi Jeroen, > > > > > > Hey, interesting. You'd have to override more methods than that > > > though, I think. Maybe the best solution would be to override in > > > gnu.java.nio.channels.FileChannelImpl and create a > > > FileOutputStream with that as its argument. > > > > > > I'll have a proper think about it when I change the exception > > > messages. I'm deep in something else at the moment. > > > > > > Cheers, > > > Gary > > > > > > Jeroen Frijters wrote: > > > > Hi Gary, > > > > > > > > Sorry for the late response, but a somewhat easier (and > > > more efficient) > > > > way to fix the problem would have been: > > > > > > > > + if ((fdmode & FileChannelImpl.WRITE) != 0) > > > > + out = new DataOutputStream (new FileOutputStream (fd)); > > > > + else > > > > + out = new DataOutputStream (new FilterOutputStream() { > > > > + public void write(int b) throws IOException { > > > > + throw new IOException("Bad file descriptor"); > > > > + } > > > > + }); > > > > > > > > Regards, > > > > Jeroen > > > > > > > > > -----Original Message----- > > > > > From: [EMAIL PROTECTED] > > > > > [mailto:[EMAIL PROTECTED] > > > > > On Behalf Of Gary Benson > > > > > Sent: Wednesday, December 07, 2005 16:32 > > > > > To: [email protected] > > > > > Subject: [cp-patches] FYI: Opening RandomAccessFiles requires > > > > > excessivepermission > > > > > > > > > > Hi all, > > > > > > > > > > As promised, I committed my fix that means you don't need > > > > > permission to write file descriptors to open a > > > > > java.io.RandomAccessFile in read-only mode under a security > > > > > manager. > > > > > > > > > > Cheers, > > > > > Gary > > > _______________________________________________ > Classpath-patches mailing list > [email protected] > http://lists.gnu.org/mailman/listinfo/classpath-patches > _______________________________________________ Classpath-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/classpath-patches
