classpath-patches
[Top][All Lists]
Advanced

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

Re: [cp-patches] FYI: Opening RandomAccessFiles requires excessivepermis


From: David Daney
Subject: Re: [cp-patches] FYI: Opening RandomAccessFiles requires excessivepermission
Date: Thu, 08 Dec 2005 08:14:10 -0800
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)

Gary Benson wrote:
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");
+              }
+            });

I think that this is a good approach. There is a small typo in the else clause. The anonymous inner class would extend OutputStream.

An alternative would be to take the inner class and make it a public class in gnu.java.io.??? that could be used in other similar situations. Its constructor could take a String parameter which would be the exception message.

David Daney.





reply via email to

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