From 2d8cf20d0d5ca6b1fbdefc22229d4b7cf1497ede Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 17 Jan 2006 18:09:40 +0000 Subject: Imported GNU Classpath 0.20 * Makefile.am (AM_CPPFLAGS): Add classpath/include. * java/nio/charset/spi/CharsetProvider.java: New override file. * java/security/Security.java: Likewise. * sources.am: Regenerated. * Makefile.in: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109831 138bc75d-0d04-0410-961f-82ee72b054a4 --- .../classpath/gnu/java/nio/charset/Provider.java | 27 ++++++++++++++-------- .../gnu/java/nio/charset/iconv/IconvProvider.java | 15 +++++------- 2 files changed, 23 insertions(+), 19 deletions(-) (limited to 'libjava/classpath/gnu/java/nio/charset') diff --git a/libjava/classpath/gnu/java/nio/charset/Provider.java b/libjava/classpath/gnu/java/nio/charset/Provider.java index 3f25c598851..01c2650a81b 100644 --- a/libjava/classpath/gnu/java/nio/charset/Provider.java +++ b/libjava/classpath/gnu/java/nio/charset/Provider.java @@ -1,5 +1,5 @@ /* Provider.java -- - Copyright (C) 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,6 +39,8 @@ package gnu.java.nio.charset; 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; @@ -47,6 +49,11 @@ import java.util.Iterator; * Charset provider for the required charsets. Used by * {@link Charset#charsetForName} and * {@link Charset#availableCharsets}. * + * Note: This class is a privileged class, because it can be instantiated without + * requiring the RuntimePermission("charsetProvider"). There is a check in + * java.nio.charset.spi.CharsetProvider to skip the security check if the provider + * is an instance of this class. + * * @author Jesse Rosenstock * @author Robert Schuster (thebohemian@gmx.net) * @see Charset @@ -55,14 +62,6 @@ public final class Provider extends CharsetProvider { private static Provider singleton; - static - { - synchronized (Provider.class) - { - singleton = null; - } - } - /** * Map from charset name to charset canonical name. The strings * are all lower-case to allow case-insensitive retrieval of @@ -232,8 +231,16 @@ public final class Provider extends CharsetProvider 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; } } diff --git a/libjava/classpath/gnu/java/nio/charset/iconv/IconvProvider.java b/libjava/classpath/gnu/java/nio/charset/iconv/IconvProvider.java index 873e9ecda41..6fd8b744082 100644 --- a/libjava/classpath/gnu/java/nio/charset/iconv/IconvProvider.java +++ b/libjava/classpath/gnu/java/nio/charset/iconv/IconvProvider.java @@ -1,5 +1,5 @@ /* IconvProvider.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,20 +48,17 @@ import java.util.Vector; /** * Charset provider wrapping iconv. * + * Note: This class is a privileged class, because it can be instantiated without + * requiring the RuntimePermission("charsetProvider"). There is a check in + * java.nio.charset.spi.CharsetProvider to skip the security check if the provider + * is an instance of this class. + * * @author Sven de Marothy */ public final class IconvProvider extends CharsetProvider { private static IconvProvider singleton; - static - { - synchronized (IconvProvider.class) - { - singleton = null; - } - } - // Declaring the construtor public may violate the use of singleton. // But it must be public so that an instance of this class can be // created by Class.newInstance(), which is the case when this provider is -- cgit v1.2.3