diff -r 588d5bf7a560 -r 802e5d2da9f6 rt/emul/compact/src/main/java/java/nio/charset/Charset.java
--- a/rt/emul/compact/src/main/java/java/nio/charset/Charset.java Thu Oct 03 15:40:35 2013 +0200
+++ b/rt/emul/compact/src/main/java/java/nio/charset/Charset.java Fri Oct 04 15:02:17 2013 +0200
@@ -25,27 +25,16 @@
package java.nio.charset;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.spi.CharsetProvider;
-import java.security.AccessController;
-import java.security.AccessControlException;
-import java.security.PrivilegedAction;
+//import java.nio.ByteBuffer;
+//import java.nio.CharBuffer;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
-import java.util.NoSuchElementException;
import java.util.Set;
-import java.util.ServiceLoader;
-import java.util.ServiceConfigurationError;
import java.util.SortedMap;
import java.util.TreeMap;
-import sun.misc.ASCIICaseInsensitiveComparator;
-import sun.nio.cs.StandardCharsets;
-import sun.nio.cs.ThreadLocalCoders;
-import sun.security.action.GetPropertyAction;
/**
@@ -281,17 +270,6 @@
private static volatile String bugLevel = null;
- static boolean atBugLevel(String bl) { // package-private
- String level = bugLevel;
- if (level == null) {
- if (!sun.misc.VM.isBooted())
- return false;
- bugLevel = level = AccessController.doPrivileged(
- new GetPropertyAction("sun.nio.cs.bugLevel", ""));
- }
- return level.equals(bl);
- }
-
/**
* Checks that the given string is a legal charset name.
*
@@ -303,10 +281,8 @@
*/
private static void checkName(String s) {
int n = s.length();
- if (!atBugLevel("1.4")) {
if (n == 0)
throw new IllegalCharsetNameException(s);
- }
for (int i = 0; i < n; i++) {
char c = s.charAt(i);
if (c >= 'A' && c <= 'Z') continue;
@@ -321,9 +297,6 @@
}
}
- /* The standard set of charsets */
- private static CharsetProvider standardProvider = new StandardCharsets();
-
// Cache of the most-recently-returned charsets,
// along with the names that were used to find them
//
@@ -340,126 +313,23 @@
// thrown. Should be invoked with full privileges.
//
private static Iterator providers() {
- return new Iterator() {
-
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- ServiceLoader sl =
- ServiceLoader.load(CharsetProvider.class, cl);
- Iterator i = sl.iterator();
-
- Object next = null;
-
- private boolean getNext() {
- while (next == null) {
- try {
- if (!i.hasNext())
- return false;
- next = i.next();
- } catch (ServiceConfigurationError sce) {
- if (sce.getCause() instanceof SecurityException) {
- // Ignore security exceptions
- continue;
- }
- throw sce;
- }
- }
- return true;
- }
-
- public boolean hasNext() {
- return getNext();
- }
-
- public Object next() {
- if (!getNext())
- throw new NoSuchElementException();
- Object n = next;
- next = null;
- return n;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- };
+ return Collections.emptyIterator();
}
// Thread-local gate to prevent recursive provider lookups
private static ThreadLocal gate = new ThreadLocal();
private static Charset lookupViaProviders(final String charsetName) {
-
- // The runtime startup sequence looks up standard charsets as a
- // consequence of the VM's invocation of System.initializeSystemClass
- // in order to, e.g., set system properties and encode filenames. At
- // that point the application class loader has not been initialized,
- // however, so we can't look for providers because doing so will cause
- // that loader to be prematurely initialized with incomplete
- // information.
- //
- if (!sun.misc.VM.isBooted())
- return null;
-
- if (gate.get() != null)
- // Avoid recursive provider lookups
- return null;
- try {
- gate.set(gate);
-
- return AccessController.doPrivileged(
- new PrivilegedAction() {
- public Charset run() {
- for (Iterator i = providers(); i.hasNext();) {
- CharsetProvider cp = (CharsetProvider)i.next();
- Charset cs = cp.charsetForName(charsetName);
- if (cs != null)
- return cs;
- }
- return null;
- }
- });
-
- } finally {
- gate.set(null);
- }
+ return null;
}
/* The extended set of charsets */
private static Object extendedProviderLock = new Object();
private static boolean extendedProviderProbed = false;
- private static CharsetProvider extendedProvider = null;
- private static void probeExtendedProvider() {
- AccessController.doPrivileged(new PrivilegedAction