Hi Gary (and moved to classpath-patches),

On Thu, 2005-12-22 at 15:15 +0000, Gary Benson wrote:
> > Aha! There is your clue. libgcj hasn't merged in the new nio charset
> > provider setup. And indeed creating a new CharsetProvider requires a
> > RuntimePermission("charsetProvider"). Even for creating the default
> > provider. Which obviously should always be created, otherwise
> > nothing works. It is safe in this case since we know the default
> > provider doesn't do nasty things (or at least we hope so). So you
> > need the attached patch to gnu/java/nio/charset/Provider.java.
> 
> Works perfectly, thanks.

And so this will be checked in:

2005-12-22  Mark Wielaard  <[EMAIL PROTECTED]>

    * gnu/java/nio/charset/Provider.java (provider): Wrap initialization
    of standard provider in a PrivilegedAction.

Cheers,

Mark
Index: gnu/java/nio/charset/Provider.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/nio/charset/Provider.java,v
retrieving revision 1.6
diff -u -r1.6 Provider.java
--- gnu/java/nio/charset/Provider.java	2 Jul 2005 20:32:13 -0000	1.6
+++ gnu/java/nio/charset/Provider.java	13 Dec 2005 18:38:18 -0000
@@ -39,6 +39,8 @@
 
 import java.nio.charset.Charset;
 import java.nio.charset.spi.CharsetProvider;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -232,8 +234,16 @@
 
   public static synchronized Provider provider ()
   {
+    // The default provider is safe to instantiate.
     if (singleton == null)
-      singleton = new Provider ();
+      singleton = (Provider) AccessController.doPrivileged
+	(new PrivilegedAction()
+	  {
+	    public Object run()
+	    {
+	      return new Provider();
+	    }
+	  });
     return singleton;
   }
 }

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

_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to