Charset can be compiled now
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Fri, 04 Oct 2013 15:02:17 +0200
changeset 1343802e5d2da9f6
parent 1342 44015f05c91b
child 1344 bb1e59f5cff3
Charset can be compiled now
rt/emul/compact/src/main/java/java/io/OutputStreamWriter.java
rt/emul/compact/src/main/java/java/io/PrintStream.java
rt/emul/compact/src/main/java/java/io/PrintWriter.java
rt/emul/compact/src/main/java/java/nio/charset/Charset.java
rt/emul/compact/src/main/java/java/nio/charset/CharsetDecoder.java
rt/emul/compact/src/main/java/java/nio/charset/CharsetEncoder.java
     1.1 --- a/rt/emul/compact/src/main/java/java/io/OutputStreamWriter.java	Fri Oct 04 15:01:04 2013 +0200
     1.2 +++ b/rt/emul/compact/src/main/java/java/io/OutputStreamWriter.java	Fri Oct 04 15:02:17 2013 +0200
     1.3 @@ -25,6 +25,8 @@
     1.4  
     1.5  package java.io;
     1.6  
     1.7 +import java.nio.charset.Charset;
     1.8 +
     1.9  /**
    1.10   * An OutputStreamWriter is a bridge from character streams to byte streams:
    1.11   * Characters written to it are encoded into bytes using a specified {@link
    1.12 @@ -116,12 +118,9 @@
    1.13       * @since 1.4
    1.14       * @spec JSR-51
    1.15       */
    1.16 -//    public OutputStreamWriter(OutputStream out, Charset cs) {
    1.17 -//        super(out);
    1.18 -//        if (cs == null)
    1.19 -//            throw new NullPointerException("charset");
    1.20 -//        se = StreamEncoder.forOutputStreamWriter(out, this, cs);
    1.21 -//    }
    1.22 +    public OutputStreamWriter(OutputStream out, Charset cs) {
    1.23 +        this(out);
    1.24 +    }
    1.25  
    1.26      /**
    1.27       * Creates an OutputStreamWriter that uses the given charset encoder.  </p>
     2.1 --- a/rt/emul/compact/src/main/java/java/io/PrintStream.java	Fri Oct 04 15:01:04 2013 +0200
     2.2 +++ b/rt/emul/compact/src/main/java/java/io/PrintStream.java	Fri Oct 04 15:02:17 2013 +0200
     2.3 @@ -25,6 +25,7 @@
     2.4  
     2.5  package java.io;
     2.6  
     2.7 +import java.nio.charset.Charset;
     2.8  import java.util.Arrays;
     2.9  
    2.10  
    2.11 @@ -88,9 +89,6 @@
    2.12      static final class Formatter {
    2.13      }
    2.14      
    2.15 -    static final class Charset {
    2.16 -    }
    2.17 -    
    2.18      static Charset toCharset(String ch) throws UnsupportedEncodingException {
    2.19          if (!"UTF-8".equals(ch)) {
    2.20              throw new UnsupportedEncodingException();
     3.1 --- a/rt/emul/compact/src/main/java/java/io/PrintWriter.java	Fri Oct 04 15:01:04 2013 +0200
     3.2 +++ b/rt/emul/compact/src/main/java/java/io/PrintWriter.java	Fri Oct 04 15:02:17 2013 +0200
     3.3 @@ -25,10 +25,9 @@
     3.4  
     3.5  package java.io;
     3.6  
     3.7 -import java.io.PrintStream.Charset;
     3.8  import java.io.PrintStream.Formatter;
     3.9 +import java.nio.charset.Charset;
    3.10  import java.util.Arrays;
    3.11 -import java.util.Objects;
    3.12  
    3.13  /**
    3.14   * Prints formatted representations of objects to a text-output stream.  This
     4.1 --- a/rt/emul/compact/src/main/java/java/nio/charset/Charset.java	Fri Oct 04 15:01:04 2013 +0200
     4.2 +++ b/rt/emul/compact/src/main/java/java/nio/charset/Charset.java	Fri Oct 04 15:02:17 2013 +0200
     4.3 @@ -25,27 +25,16 @@
     4.4  
     4.5  package java.nio.charset;
     4.6  
     4.7 -import java.nio.ByteBuffer;
     4.8 -import java.nio.CharBuffer;
     4.9 -import java.nio.charset.spi.CharsetProvider;
    4.10 -import java.security.AccessController;
    4.11 -import java.security.AccessControlException;
    4.12 -import java.security.PrivilegedAction;
    4.13 +//import java.nio.ByteBuffer;
    4.14 +//import java.nio.CharBuffer;
    4.15  import java.util.Collections;
    4.16  import java.util.HashSet;
    4.17  import java.util.Iterator;
    4.18  import java.util.Locale;
    4.19  import java.util.Map;
    4.20 -import java.util.NoSuchElementException;
    4.21  import java.util.Set;
    4.22 -import java.util.ServiceLoader;
    4.23 -import java.util.ServiceConfigurationError;
    4.24  import java.util.SortedMap;
    4.25  import java.util.TreeMap;
    4.26 -import sun.misc.ASCIICaseInsensitiveComparator;
    4.27 -import sun.nio.cs.StandardCharsets;
    4.28 -import sun.nio.cs.ThreadLocalCoders;
    4.29 -import sun.security.action.GetPropertyAction;
    4.30  
    4.31  
    4.32  /**
    4.33 @@ -281,17 +270,6 @@
    4.34  
    4.35      private static volatile String bugLevel = null;
    4.36  
    4.37 -    static boolean atBugLevel(String bl) {              // package-private
    4.38 -        String level = bugLevel;
    4.39 -        if (level == null) {
    4.40 -            if (!sun.misc.VM.isBooted())
    4.41 -                return false;
    4.42 -            bugLevel = level = AccessController.doPrivileged(
    4.43 -                new GetPropertyAction("sun.nio.cs.bugLevel", ""));
    4.44 -        }
    4.45 -        return level.equals(bl);
    4.46 -    }
    4.47 -
    4.48      /**
    4.49       * Checks that the given string is a legal charset name. </p>
    4.50       *
    4.51 @@ -303,10 +281,8 @@
    4.52       */
    4.53      private static void checkName(String s) {
    4.54          int n = s.length();
    4.55 -        if (!atBugLevel("1.4")) {
    4.56              if (n == 0)
    4.57                  throw new IllegalCharsetNameException(s);
    4.58 -        }
    4.59          for (int i = 0; i < n; i++) {
    4.60              char c = s.charAt(i);
    4.61              if (c >= 'A' && c <= 'Z') continue;
    4.62 @@ -321,9 +297,6 @@
    4.63          }
    4.64      }
    4.65  
    4.66 -    /* The standard set of charsets */
    4.67 -    private static CharsetProvider standardProvider = new StandardCharsets();
    4.68 -
    4.69      // Cache of the most-recently-returned charsets,
    4.70      // along with the names that were used to find them
    4.71      //
    4.72 @@ -340,126 +313,23 @@
    4.73      // thrown.  Should be invoked with full privileges.
    4.74      //
    4.75      private static Iterator providers() {
    4.76 -        return new Iterator() {
    4.77 -
    4.78 -                ClassLoader cl = ClassLoader.getSystemClassLoader();
    4.79 -                ServiceLoader<CharsetProvider> sl =
    4.80 -                    ServiceLoader.load(CharsetProvider.class, cl);
    4.81 -                Iterator<CharsetProvider> i = sl.iterator();
    4.82 -
    4.83 -                Object next = null;
    4.84 -
    4.85 -                private boolean getNext() {
    4.86 -                    while (next == null) {
    4.87 -                        try {
    4.88 -                            if (!i.hasNext())
    4.89 -                                return false;
    4.90 -                            next = i.next();
    4.91 -                        } catch (ServiceConfigurationError sce) {
    4.92 -                            if (sce.getCause() instanceof SecurityException) {
    4.93 -                                // Ignore security exceptions
    4.94 -                                continue;
    4.95 -                            }
    4.96 -                            throw sce;
    4.97 -                        }
    4.98 -                    }
    4.99 -                    return true;
   4.100 -                }
   4.101 -
   4.102 -                public boolean hasNext() {
   4.103 -                    return getNext();
   4.104 -                }
   4.105 -
   4.106 -                public Object next() {
   4.107 -                    if (!getNext())
   4.108 -                        throw new NoSuchElementException();
   4.109 -                    Object n = next;
   4.110 -                    next = null;
   4.111 -                    return n;
   4.112 -                }
   4.113 -
   4.114 -                public void remove() {
   4.115 -                    throw new UnsupportedOperationException();
   4.116 -                }
   4.117 -
   4.118 -            };
   4.119 +        return Collections.emptyIterator();
   4.120      }
   4.121  
   4.122      // Thread-local gate to prevent recursive provider lookups
   4.123      private static ThreadLocal<ThreadLocal> gate = new ThreadLocal<ThreadLocal>();
   4.124  
   4.125      private static Charset lookupViaProviders(final String charsetName) {
   4.126 -
   4.127 -        // The runtime startup sequence looks up standard charsets as a
   4.128 -        // consequence of the VM's invocation of System.initializeSystemClass
   4.129 -        // in order to, e.g., set system properties and encode filenames.  At
   4.130 -        // that point the application class loader has not been initialized,
   4.131 -        // however, so we can't look for providers because doing so will cause
   4.132 -        // that loader to be prematurely initialized with incomplete
   4.133 -        // information.
   4.134 -        //
   4.135 -        if (!sun.misc.VM.isBooted())
   4.136 -            return null;
   4.137 -
   4.138 -        if (gate.get() != null)
   4.139 -            // Avoid recursive provider lookups
   4.140 -            return null;
   4.141 -        try {
   4.142 -            gate.set(gate);
   4.143 -
   4.144 -            return AccessController.doPrivileged(
   4.145 -                new PrivilegedAction<Charset>() {
   4.146 -                    public Charset run() {
   4.147 -                        for (Iterator i = providers(); i.hasNext();) {
   4.148 -                            CharsetProvider cp = (CharsetProvider)i.next();
   4.149 -                            Charset cs = cp.charsetForName(charsetName);
   4.150 -                            if (cs != null)
   4.151 -                                return cs;
   4.152 -                        }
   4.153 -                        return null;
   4.154 -                    }
   4.155 -                });
   4.156 -
   4.157 -        } finally {
   4.158 -            gate.set(null);
   4.159 -        }
   4.160 +        return null;
   4.161      }
   4.162  
   4.163      /* The extended set of charsets */
   4.164      private static Object extendedProviderLock = new Object();
   4.165      private static boolean extendedProviderProbed = false;
   4.166 -    private static CharsetProvider extendedProvider = null;
   4.167  
   4.168 -    private static void probeExtendedProvider() {
   4.169 -        AccessController.doPrivileged(new PrivilegedAction<Object>() {
   4.170 -                public Object run() {
   4.171 -                    try {
   4.172 -                        Class epc
   4.173 -                            = Class.forName("sun.nio.cs.ext.ExtendedCharsets");
   4.174 -                        extendedProvider = (CharsetProvider)epc.newInstance();
   4.175 -                    } catch (ClassNotFoundException x) {
   4.176 -                        // Extended charsets not available
   4.177 -                        // (charsets.jar not present)
   4.178 -                    } catch (InstantiationException x) {
   4.179 -                        throw new Error(x);
   4.180 -                    } catch (IllegalAccessException x) {
   4.181 -                        throw new Error(x);
   4.182 -                    }
   4.183 -                    return null;
   4.184 -                }
   4.185 -            });
   4.186 -    }
   4.187  
   4.188      private static Charset lookupExtendedCharset(String charsetName) {
   4.189 -        CharsetProvider ecp = null;
   4.190 -        synchronized (extendedProviderLock) {
   4.191 -            if (!extendedProviderProbed) {
   4.192 -                probeExtendedProvider();
   4.193 -                extendedProviderProbed = true;
   4.194 -            }
   4.195 -            ecp = extendedProvider;
   4.196 -        }
   4.197 -        return (ecp != null) ? ecp.charsetForName(charsetName) : null;
   4.198 +        return null;
   4.199      }
   4.200  
   4.201      private static Charset lookup(String charsetName) {
   4.202 @@ -483,15 +353,6 @@
   4.203              return (Charset)a[1];
   4.204          }
   4.205  
   4.206 -        Charset cs;
   4.207 -        if ((cs = standardProvider.charsetForName(charsetName)) != null ||
   4.208 -            (cs = lookupExtendedCharset(charsetName))           != null ||
   4.209 -            (cs = lookupViaProviders(charsetName))              != null)
   4.210 -        {
   4.211 -            cache(charsetName, cs);
   4.212 -            return cs;
   4.213 -        }
   4.214 -
   4.215          /* Only need to check the name if we didn't find a charset for it */
   4.216          checkName(charsetName);
   4.217          return null;
   4.218 @@ -581,20 +442,9 @@
   4.219       *         to charset objects
   4.220       */
   4.221      public static SortedMap<String,Charset> availableCharsets() {
   4.222 -        return AccessController.doPrivileged(
   4.223 -            new PrivilegedAction<SortedMap<String,Charset>>() {
   4.224 -                public SortedMap<String,Charset> run() {
   4.225 -                    TreeMap<String,Charset> m =
   4.226 -                        new TreeMap<String,Charset>(
   4.227 -                            ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
   4.228 -                    put(standardProvider.charsets(), m);
   4.229 -                    for (Iterator i = providers(); i.hasNext();) {
   4.230 -                        CharsetProvider cp = (CharsetProvider)i.next();
   4.231 -                        put(cp.charsets(), m);
   4.232 -                    }
   4.233 -                    return Collections.unmodifiableSortedMap(m);
   4.234 -                }
   4.235 -            });
   4.236 +        TreeMap<String, Charset> tm = new TreeMap<String,Charset>();
   4.237 +        tm.put("UTF-8", Charset.defaultCharset());
   4.238 +        return tm;
   4.239      }
   4.240  
   4.241      private static volatile Charset defaultCharset;
   4.242 @@ -612,15 +462,7 @@
   4.243       */
   4.244      public static Charset defaultCharset() {
   4.245          if (defaultCharset == null) {
   4.246 -            synchronized (Charset.class) {
   4.247 -                String csn = AccessController.doPrivileged(
   4.248 -                    new GetPropertyAction("file.encoding"));
   4.249 -                Charset cs = lookup(csn);
   4.250 -                if (cs != null)
   4.251 -                    defaultCharset = cs;
   4.252 -                else
   4.253 -                    defaultCharset = forName("UTF-8");
   4.254 -            }
   4.255 +            defaultCharset = forName("UTF-8");
   4.256          }
   4.257          return defaultCharset;
   4.258      }
   4.259 @@ -805,16 +647,16 @@
   4.260       *
   4.261       * @return  A char buffer containing the decoded characters
   4.262       */
   4.263 -    public final CharBuffer decode(ByteBuffer bb) {
   4.264 -        try {
   4.265 -            return ThreadLocalCoders.decoderFor(this)
   4.266 -                .onMalformedInput(CodingErrorAction.REPLACE)
   4.267 -                .onUnmappableCharacter(CodingErrorAction.REPLACE)
   4.268 -                .decode(bb);
   4.269 -        } catch (CharacterCodingException x) {
   4.270 -            throw new Error(x);         // Can't happen
   4.271 -        }
   4.272 -    }
   4.273 +//    public final CharBuffer decode(ByteBuffer bb) {
   4.274 +//        try {
   4.275 +//            return ThreadLocalCoders.decoderFor(this)
   4.276 +//                .onMalformedInput(CodingErrorAction.REPLACE)
   4.277 +//                .onUnmappableCharacter(CodingErrorAction.REPLACE)
   4.278 +//                .decode(bb);
   4.279 +//        } catch (CharacterCodingException x) {
   4.280 +//            throw new Error(x);         // Can't happen
   4.281 +//        }
   4.282 +//    }
   4.283  
   4.284      /**
   4.285       * Convenience method that encodes Unicode characters into bytes in this
   4.286 @@ -841,16 +683,16 @@
   4.287       *
   4.288       * @return  A byte buffer containing the encoded characters
   4.289       */
   4.290 -    public final ByteBuffer encode(CharBuffer cb) {
   4.291 -        try {
   4.292 -            return ThreadLocalCoders.encoderFor(this)
   4.293 -                .onMalformedInput(CodingErrorAction.REPLACE)
   4.294 -                .onUnmappableCharacter(CodingErrorAction.REPLACE)
   4.295 -                .encode(cb);
   4.296 -        } catch (CharacterCodingException x) {
   4.297 -            throw new Error(x);         // Can't happen
   4.298 -        }
   4.299 -    }
   4.300 +//    public final ByteBuffer encode(CharBuffer cb) {
   4.301 +//        try {
   4.302 +//            return ThreadLocalCoders.encoderFor(this)
   4.303 +//                .onMalformedInput(CodingErrorAction.REPLACE)
   4.304 +//                .onUnmappableCharacter(CodingErrorAction.REPLACE)
   4.305 +//                .encode(cb);
   4.306 +//        } catch (CharacterCodingException x) {
   4.307 +//            throw new Error(x);         // Can't happen
   4.308 +//        }
   4.309 +//    }
   4.310  
   4.311      /**
   4.312       * Convenience method that encodes a string into bytes in this charset.
   4.313 @@ -865,9 +707,9 @@
   4.314       *
   4.315       * @return  A byte buffer containing the encoded characters
   4.316       */
   4.317 -    public final ByteBuffer encode(String str) {
   4.318 -        return encode(CharBuffer.wrap(str));
   4.319 -    }
   4.320 +//    public final ByteBuffer encode(String str) {
   4.321 +//        return encode(CharBuffer.wrap(str));
   4.322 +//    }
   4.323  
   4.324      /**
   4.325       * Compares this charset to another.
     5.1 --- a/rt/emul/compact/src/main/java/java/nio/charset/CharsetDecoder.java	Fri Oct 04 15:01:04 2013 +0200
     5.2 +++ b/rt/emul/compact/src/main/java/java/nio/charset/CharsetDecoder.java	Fri Oct 04 15:02:17 2013 +0200
     5.3 @@ -27,13 +27,13 @@
     5.4  
     5.5  package java.nio.charset;
     5.6  
     5.7 -import java.nio.Buffer;
     5.8 -import java.nio.ByteBuffer;
     5.9 -import java.nio.CharBuffer;
    5.10 -import java.nio.BufferOverflowException;
    5.11 -import java.nio.BufferUnderflowException;
    5.12 +//import java.nio.Buffer;
    5.13 +//import java.nio.ByteBuffer;
    5.14 +//import java.nio.CharBuffer;
    5.15 +//import java.nio.BufferOverflowException;
    5.16 +//import java.nio.BufferUnderflowException;
    5.17  import java.lang.ref.WeakReference;
    5.18 -import java.nio.charset.CoderMalfunctionError;                  // javadoc
    5.19 +//import java.nio.charset.CoderMalfunctionError;                  // javadoc
    5.20  
    5.21  
    5.22  /**
    5.23 @@ -140,10 +140,10 @@
    5.24      private final float maxCharsPerByte;
    5.25  
    5.26      private String replacement;
    5.27 -    private CodingErrorAction malformedInputAction
    5.28 -        = CodingErrorAction.REPORT;
    5.29 -    private CodingErrorAction unmappableCharacterAction
    5.30 -        = CodingErrorAction.REPORT;
    5.31 +//    private CodingErrorAction malformedInputAction
    5.32 +//        = CodingErrorAction.REPORT;
    5.33 +//    private CodingErrorAction unmappableCharacterAction
    5.34 +//        = CodingErrorAction.REPORT;
    5.35  
    5.36      // Internal states
    5.37      //
    5.38 @@ -191,12 +191,10 @@
    5.39          if (maxCharsPerByte <= 0.0f)
    5.40              throw new IllegalArgumentException("Non-positive "
    5.41                                                 + "maxCharsPerByte");
    5.42 -        if (!Charset.atBugLevel("1.4")) {
    5.43 -            if (averageCharsPerByte > maxCharsPerByte)
    5.44 -                throw new IllegalArgumentException("averageCharsPerByte"
    5.45 -                                                   + " exceeds "
    5.46 -                                                   + "maxCharsPerByte");
    5.47 -        }
    5.48 +        if (averageCharsPerByte > maxCharsPerByte)
    5.49 +            throw new IllegalArgumentException("averageCharsPerByte"
    5.50 +                                               + " exceeds "
    5.51 +                                               + "maxCharsPerByte");
    5.52          this.replacement = replacement;
    5.53          this.averageCharsPerByte = averageCharsPerByte;
    5.54          this.maxCharsPerByte = maxCharsPerByte;
    5.55 @@ -346,9 +344,9 @@
    5.56       *
    5.57       * @return The current malformed-input action, which is never <tt>null</tt>
    5.58       */
    5.59 -    public CodingErrorAction malformedInputAction() {
    5.60 -        return malformedInputAction;
    5.61 -    }
    5.62 +//    public CodingErrorAction malformedInputAction() {
    5.63 +//        return malformedInputAction;
    5.64 +//    }
    5.65  
    5.66      /**
    5.67       * Changes this decoder's action for malformed-input errors.  </p>
    5.68 @@ -363,13 +361,13 @@
    5.69       * @throws IllegalArgumentException
    5.70       *         If the precondition on the parameter does not hold
    5.71       */
    5.72 -    public final CharsetDecoder onMalformedInput(CodingErrorAction newAction) {
    5.73 -        if (newAction == null)
    5.74 -            throw new IllegalArgumentException("Null action");
    5.75 -        malformedInputAction = newAction;
    5.76 -        implOnMalformedInput(newAction);
    5.77 -        return this;
    5.78 -    }
    5.79 +//    public final CharsetDecoder onMalformedInput(CodingErrorAction newAction) {
    5.80 +//        if (newAction == null)
    5.81 +//            throw new IllegalArgumentException("Null action");
    5.82 +//        malformedInputAction = newAction;
    5.83 +//        implOnMalformedInput(newAction);
    5.84 +//        return this;
    5.85 +//    }
    5.86  
    5.87      /**
    5.88       * Reports a change to this decoder's malformed-input action.
    5.89 @@ -378,7 +376,7 @@
    5.90       * should be overridden by decoders that require notification of changes to
    5.91       * the malformed-input action.  </p>
    5.92       */
    5.93 -    protected void implOnMalformedInput(CodingErrorAction newAction) { }
    5.94 +//    protected void implOnMalformedInput(CodingErrorAction newAction) { }
    5.95  
    5.96      /**
    5.97       * Returns this decoder's current action for unmappable-character errors.
    5.98 @@ -387,9 +385,9 @@
    5.99       * @return The current unmappable-character action, which is never
   5.100       *         <tt>null</tt>
   5.101       */
   5.102 -    public CodingErrorAction unmappableCharacterAction() {
   5.103 -        return unmappableCharacterAction;
   5.104 -    }
   5.105 +//    public CodingErrorAction unmappableCharacterAction() {
   5.106 +//        return unmappableCharacterAction;
   5.107 +//    }
   5.108  
   5.109      /**
   5.110       * Changes this decoder's action for unmappable-character errors.
   5.111 @@ -404,15 +402,15 @@
   5.112       * @throws IllegalArgumentException
   5.113       *         If the precondition on the parameter does not hold
   5.114       */
   5.115 -    public final CharsetDecoder onUnmappableCharacter(CodingErrorAction
   5.116 -                                                      newAction)
   5.117 -    {
   5.118 -        if (newAction == null)
   5.119 -            throw new IllegalArgumentException("Null action");
   5.120 -        unmappableCharacterAction = newAction;
   5.121 -        implOnUnmappableCharacter(newAction);
   5.122 -        return this;
   5.123 -    }
   5.124 +//    public final CharsetDecoder onUnmappableCharacter(CodingErrorAction
   5.125 +//                                                      newAction)
   5.126 +//    {
   5.127 +//        if (newAction == null)
   5.128 +//            throw new IllegalArgumentException("Null action");
   5.129 +//        unmappableCharacterAction = newAction;
   5.130 +//        implOnUnmappableCharacter(newAction);
   5.131 +//        return this;
   5.132 +//    }
   5.133  
   5.134      /**
   5.135       * Reports a change to this decoder's unmappable-character action.
   5.136 @@ -421,7 +419,7 @@
   5.137       * should be overridden by decoders that require notification of changes to
   5.138       * the unmappable-character action.  </p>
   5.139       */
   5.140 -    protected void implOnUnmappableCharacter(CodingErrorAction newAction) { }
   5.141 +//    protected void implOnUnmappableCharacter(CodingErrorAction newAction) { }
   5.142  
   5.143      /**
   5.144       * Returns the average number of characters that will be produced for each
   5.145 @@ -545,66 +543,66 @@
   5.146       *          If an invocation of the decodeLoop method threw
   5.147       *          an unexpected exception
   5.148       */
   5.149 -    public final CoderResult decode(ByteBuffer in, CharBuffer out,
   5.150 -                                    boolean endOfInput)
   5.151 -    {
   5.152 -        int newState = endOfInput ? ST_END : ST_CODING;
   5.153 -        if ((state != ST_RESET) && (state != ST_CODING)
   5.154 -            && !(endOfInput && (state == ST_END)))
   5.155 -            throwIllegalStateException(state, newState);
   5.156 -        state = newState;
   5.157 -
   5.158 -        for (;;) {
   5.159 -
   5.160 -            CoderResult cr;
   5.161 -            try {
   5.162 -                cr = decodeLoop(in, out);
   5.163 -            } catch (BufferUnderflowException x) {
   5.164 -                throw new CoderMalfunctionError(x);
   5.165 -            } catch (BufferOverflowException x) {
   5.166 -                throw new CoderMalfunctionError(x);
   5.167 -            }
   5.168 -
   5.169 -            if (cr.isOverflow())
   5.170 -                return cr;
   5.171 -
   5.172 -            if (cr.isUnderflow()) {
   5.173 -                if (endOfInput && in.hasRemaining()) {
   5.174 -                    cr = CoderResult.malformedForLength(in.remaining());
   5.175 -                    // Fall through to malformed-input case
   5.176 -                } else {
   5.177 -                    return cr;
   5.178 -                }
   5.179 -            }
   5.180 -
   5.181 -            CodingErrorAction action = null;
   5.182 -            if (cr.isMalformed())
   5.183 -                action = malformedInputAction;
   5.184 -            else if (cr.isUnmappable())
   5.185 -                action = unmappableCharacterAction;
   5.186 -            else
   5.187 -                assert false : cr.toString();
   5.188 -
   5.189 -            if (action == CodingErrorAction.REPORT)
   5.190 -                return cr;
   5.191 -
   5.192 -            if (action == CodingErrorAction.REPLACE) {
   5.193 -                if (out.remaining() < replacement.length())
   5.194 -                    return CoderResult.OVERFLOW;
   5.195 -                out.put(replacement);
   5.196 -            }
   5.197 -
   5.198 -            if ((action == CodingErrorAction.IGNORE)
   5.199 -                || (action == CodingErrorAction.REPLACE)) {
   5.200 -                // Skip erroneous input either way
   5.201 -                in.position(in.position() + cr.length());
   5.202 -                continue;
   5.203 -            }
   5.204 -
   5.205 -            assert false;
   5.206 -        }
   5.207 -
   5.208 -    }
   5.209 +//    public final CoderResult decode(ByteBuffer in, CharBuffer out,
   5.210 +//                                    boolean endOfInput)
   5.211 +//    {
   5.212 +//        int newState = endOfInput ? ST_END : ST_CODING;
   5.213 +//        if ((state != ST_RESET) && (state != ST_CODING)
   5.214 +//            && !(endOfInput && (state == ST_END)))
   5.215 +//            throwIllegalStateException(state, newState);
   5.216 +//        state = newState;
   5.217 +//
   5.218 +//        for (;;) {
   5.219 +//
   5.220 +//            CoderResult cr;
   5.221 +//            try {
   5.222 +//                cr = decodeLoop(in, out);
   5.223 +//            } catch (BufferUnderflowException x) {
   5.224 +//                throw new CoderMalfunctionError(x);
   5.225 +//            } catch (BufferOverflowException x) {
   5.226 +//                throw new CoderMalfunctionError(x);
   5.227 +//            }
   5.228 +//
   5.229 +//            if (cr.isOverflow())
   5.230 +//                return cr;
   5.231 +//
   5.232 +//            if (cr.isUnderflow()) {
   5.233 +//                if (endOfInput && in.hasRemaining()) {
   5.234 +//                    cr = CoderResult.malformedForLength(in.remaining());
   5.235 +//                    // Fall through to malformed-input case
   5.236 +//                } else {
   5.237 +//                    return cr;
   5.238 +//                }
   5.239 +//            }
   5.240 +//
   5.241 +//            CodingErrorAction action = null;
   5.242 +//            if (cr.isMalformed())
   5.243 +//                action = malformedInputAction;
   5.244 +//            else if (cr.isUnmappable())
   5.245 +//                action = unmappableCharacterAction;
   5.246 +//            else
   5.247 +//                assert false : cr.toString();
   5.248 +//
   5.249 +//            if (action == CodingErrorAction.REPORT)
   5.250 +//                return cr;
   5.251 +//
   5.252 +//            if (action == CodingErrorAction.REPLACE) {
   5.253 +//                if (out.remaining() < replacement.length())
   5.254 +//                    return CoderResult.OVERFLOW;
   5.255 +//                out.put(replacement);
   5.256 +//            }
   5.257 +//
   5.258 +//            if ((action == CodingErrorAction.IGNORE)
   5.259 +//                || (action == CodingErrorAction.REPLACE)) {
   5.260 +//                // Skip erroneous input either way
   5.261 +//                in.position(in.position() + cr.length());
   5.262 +//                continue;
   5.263 +//            }
   5.264 +//
   5.265 +//            assert false;
   5.266 +//        }
   5.267 +//
   5.268 +//    }
   5.269  
   5.270      /**
   5.271       * Flushes this decoder.
   5.272 @@ -645,19 +643,19 @@
   5.273       *          with a value of <tt>true</tt> for the <tt>endOfInput</tt>
   5.274       *          parameter
   5.275       */
   5.276 -    public final CoderResult flush(CharBuffer out) {
   5.277 -        if (state == ST_END) {
   5.278 -            CoderResult cr = implFlush(out);
   5.279 -            if (cr.isUnderflow())
   5.280 -                state = ST_FLUSHED;
   5.281 -            return cr;
   5.282 -        }
   5.283 -
   5.284 -        if (state != ST_FLUSHED)
   5.285 -            throwIllegalStateException(state, ST_FLUSHED);
   5.286 -
   5.287 -        return CoderResult.UNDERFLOW; // Already flushed
   5.288 -    }
   5.289 +//    public final CoderResult flush(CharBuffer out) {
   5.290 +//        if (state == ST_END) {
   5.291 +//            CoderResult cr = implFlush(out);
   5.292 +//            if (cr.isUnderflow())
   5.293 +//                state = ST_FLUSHED;
   5.294 +//            return cr;
   5.295 +//        }
   5.296 +//
   5.297 +//        if (state != ST_FLUSHED)
   5.298 +//            throwIllegalStateException(state, ST_FLUSHED);
   5.299 +//
   5.300 +//        return CoderResult.UNDERFLOW; // Already flushed
   5.301 +//    }
   5.302  
   5.303      /**
   5.304       * Flushes this decoder.
   5.305 @@ -673,9 +671,9 @@
   5.306       * @return  A coder-result object, either {@link CoderResult#UNDERFLOW} or
   5.307       *          {@link CoderResult#OVERFLOW}
   5.308       */
   5.309 -    protected CoderResult implFlush(CharBuffer out) {
   5.310 -        return CoderResult.UNDERFLOW;
   5.311 -    }
   5.312 +//    protected CoderResult implFlush(CharBuffer out) {
   5.313 +//        return CoderResult.UNDERFLOW;
   5.314 +//    }
   5.315  
   5.316      /**
   5.317       * Resets this decoder, clearing any internal state.
   5.318 @@ -736,8 +734,8 @@
   5.319       *
   5.320       * @return  A coder-result object describing the reason for termination
   5.321       */
   5.322 -    protected abstract CoderResult decodeLoop(ByteBuffer in,
   5.323 -                                              CharBuffer out);
   5.324 +//    protected abstract CoderResult decodeLoop(ByteBuffer in,
   5.325 +//                                              CharBuffer out);
   5.326  
   5.327      /**
   5.328       * Convenience method that decodes the remaining content of a single input
   5.329 @@ -770,36 +768,36 @@
   5.330       *          the current unmappable-character action is {@link
   5.331       *          CodingErrorAction#REPORT}
   5.332       */
   5.333 -    public final CharBuffer decode(ByteBuffer in)
   5.334 -        throws CharacterCodingException
   5.335 -    {
   5.336 -        int n = (int)(in.remaining() * averageCharsPerByte());
   5.337 -        CharBuffer out = CharBuffer.allocate(n);
   5.338 -
   5.339 -        if ((n == 0) && (in.remaining() == 0))
   5.340 -            return out;
   5.341 -        reset();
   5.342 -        for (;;) {
   5.343 -            CoderResult cr = in.hasRemaining() ?
   5.344 -                decode(in, out, true) : CoderResult.UNDERFLOW;
   5.345 -            if (cr.isUnderflow())
   5.346 -                cr = flush(out);
   5.347 -
   5.348 -            if (cr.isUnderflow())
   5.349 -                break;
   5.350 -            if (cr.isOverflow()) {
   5.351 -                n = 2*n + 1;    // Ensure progress; n might be 0!
   5.352 -                CharBuffer o = CharBuffer.allocate(n);
   5.353 -                out.flip();
   5.354 -                o.put(out);
   5.355 -                out = o;
   5.356 -                continue;
   5.357 -            }
   5.358 -            cr.throwException();
   5.359 -        }
   5.360 -        out.flip();
   5.361 -        return out;
   5.362 -    }
   5.363 +//    public final CharBuffer decode(ByteBuffer in)
   5.364 +//        throws CharacterCodingException
   5.365 +//    {
   5.366 +//        int n = (int)(in.remaining() * averageCharsPerByte());
   5.367 +//        CharBuffer out = CharBuffer.allocate(n);
   5.368 +//
   5.369 +//        if ((n == 0) && (in.remaining() == 0))
   5.370 +//            return out;
   5.371 +//        reset();
   5.372 +//        for (;;) {
   5.373 +//            CoderResult cr = in.hasRemaining() ?
   5.374 +//                decode(in, out, true) : CoderResult.UNDERFLOW;
   5.375 +//            if (cr.isUnderflow())
   5.376 +//                cr = flush(out);
   5.377 +//
   5.378 +//            if (cr.isUnderflow())
   5.379 +//                break;
   5.380 +//            if (cr.isOverflow()) {
   5.381 +//                n = 2*n + 1;    // Ensure progress; n might be 0!
   5.382 +//                CharBuffer o = CharBuffer.allocate(n);
   5.383 +//                out.flip();
   5.384 +//                o.put(out);
   5.385 +//                out = o;
   5.386 +//                continue;
   5.387 +//            }
   5.388 +//            cr.throwException();
   5.389 +//        }
   5.390 +//        out.flip();
   5.391 +//        return out;
   5.392 +//    }
   5.393  
   5.394  
   5.395  
     6.1 --- a/rt/emul/compact/src/main/java/java/nio/charset/CharsetEncoder.java	Fri Oct 04 15:01:04 2013 +0200
     6.2 +++ b/rt/emul/compact/src/main/java/java/nio/charset/CharsetEncoder.java	Fri Oct 04 15:02:17 2013 +0200
     6.3 @@ -27,13 +27,13 @@
     6.4  
     6.5  package java.nio.charset;
     6.6  
     6.7 -import java.nio.Buffer;
     6.8 -import java.nio.ByteBuffer;
     6.9 -import java.nio.CharBuffer;
    6.10 -import java.nio.BufferOverflowException;
    6.11 -import java.nio.BufferUnderflowException;
    6.12 +//import java.nio.Buffer;
    6.13 +//import java.nio.ByteBuffer;
    6.14 +//import java.nio.CharBuffer;
    6.15 +//import java.nio.BufferOverflowException;
    6.16 +//import java.nio.BufferUnderflowException;
    6.17  import java.lang.ref.WeakReference;
    6.18 -import java.nio.charset.CoderMalfunctionError;                  // javadoc
    6.19 +//import java.nio.charset.CoderMalfunctionError;                  // javadoc
    6.20  
    6.21  
    6.22  /**
    6.23 @@ -140,10 +140,10 @@
    6.24      private final float maxBytesPerChar;
    6.25  
    6.26      private byte[] replacement;
    6.27 -    private CodingErrorAction malformedInputAction
    6.28 -        = CodingErrorAction.REPORT;
    6.29 -    private CodingErrorAction unmappableCharacterAction
    6.30 -        = CodingErrorAction.REPORT;
    6.31 +//    private CodingErrorAction malformedInputAction
    6.32 +//        = CodingErrorAction.REPORT;
    6.33 +//    private CodingErrorAction unmappableCharacterAction
    6.34 +//        = CodingErrorAction.REPORT;
    6.35  
    6.36      // Internal states
    6.37      //
    6.38 @@ -191,12 +191,10 @@
    6.39          if (maxBytesPerChar <= 0.0f)
    6.40              throw new IllegalArgumentException("Non-positive "
    6.41                                                 + "maxBytesPerChar");
    6.42 -        if (!Charset.atBugLevel("1.4")) {
    6.43 -            if (averageBytesPerChar > maxBytesPerChar)
    6.44 -                throw new IllegalArgumentException("averageBytesPerChar"
    6.45 -                                                   + " exceeds "
    6.46 -                                                   + "maxBytesPerChar");
    6.47 -        }
    6.48 +        if (averageBytesPerChar > maxBytesPerChar)
    6.49 +            throw new IllegalArgumentException("averageBytesPerChar"
    6.50 +                                               + " exceeds "
    6.51 +                                               + "maxBytesPerChar");
    6.52          this.replacement = replacement;
    6.53          this.averageBytesPerChar = averageBytesPerChar;
    6.54          this.maxBytesPerChar = maxBytesPerChar;
    6.55 @@ -281,8 +279,8 @@
    6.56          if (len > maxBytesPerChar)
    6.57              throw new IllegalArgumentException("Replacement too long");
    6.58  
    6.59 -        if (!isLegalReplacement(newReplacement))
    6.60 -            throw new IllegalArgumentException("Illegal replacement");
    6.61 +//        if (!isLegalReplacement(newReplacement))
    6.62 +//            throw new IllegalArgumentException("Illegal replacement");
    6.63  
    6.64          this.replacement = newReplacement;
    6.65          implReplaceWith(newReplacement);
    6.66 @@ -321,23 +319,23 @@
    6.67       * @return  <tt>true</tt> if, and only if, the given byte array
    6.68       *          is a legal replacement value for this encoder
    6.69       */
    6.70 -    public boolean isLegalReplacement(byte[] repl) {
    6.71 -        WeakReference<CharsetDecoder> wr = cachedDecoder;
    6.72 -        CharsetDecoder dec = null;
    6.73 -        if ((wr == null) || ((dec = wr.get()) == null)) {
    6.74 -            dec = charset().newDecoder();
    6.75 -            dec.onMalformedInput(CodingErrorAction.REPORT);
    6.76 -            dec.onUnmappableCharacter(CodingErrorAction.REPORT);
    6.77 -            cachedDecoder = new WeakReference<CharsetDecoder>(dec);
    6.78 -        } else {
    6.79 -            dec.reset();
    6.80 -        }
    6.81 -        ByteBuffer bb = ByteBuffer.wrap(repl);
    6.82 -        CharBuffer cb = CharBuffer.allocate((int)(bb.remaining()
    6.83 -                                                  * dec.maxCharsPerByte()));
    6.84 -        CoderResult cr = dec.decode(bb, cb, true);
    6.85 -        return !cr.isError();
    6.86 -    }
    6.87 +//    public boolean isLegalReplacement(byte[] repl) {
    6.88 +//        WeakReference<CharsetDecoder> wr = cachedDecoder;
    6.89 +//        CharsetDecoder dec = null;
    6.90 +//        if ((wr == null) || ((dec = wr.get()) == null)) {
    6.91 +//            dec = charset().newDecoder();
    6.92 +//            dec.onMalformedInput(CodingErrorAction.REPORT);
    6.93 +//            dec.onUnmappableCharacter(CodingErrorAction.REPORT);
    6.94 +//            cachedDecoder = new WeakReference<CharsetDecoder>(dec);
    6.95 +//        } else {
    6.96 +//            dec.reset();
    6.97 +//        }
    6.98 +//        ByteBuffer bb = ByteBuffer.wrap(repl);
    6.99 +//        CharBuffer cb = CharBuffer.allocate((int)(bb.remaining()
   6.100 +//                                                  * dec.maxCharsPerByte()));
   6.101 +//        CoderResult cr = dec.decode(bb, cb, true);
   6.102 +//        return !cr.isError();
   6.103 +//    }
   6.104  
   6.105  
   6.106  
   6.107 @@ -346,9 +344,9 @@
   6.108       *
   6.109       * @return The current malformed-input action, which is never <tt>null</tt>
   6.110       */
   6.111 -    public CodingErrorAction malformedInputAction() {
   6.112 -        return malformedInputAction;
   6.113 -    }
   6.114 +//    public CodingErrorAction malformedInputAction() {
   6.115 +//        return malformedInputAction;
   6.116 +//    }
   6.117  
   6.118      /**
   6.119       * Changes this encoder's action for malformed-input errors.  </p>
   6.120 @@ -363,13 +361,13 @@
   6.121       * @throws IllegalArgumentException
   6.122       *         If the precondition on the parameter does not hold
   6.123       */
   6.124 -    public final CharsetEncoder onMalformedInput(CodingErrorAction newAction) {
   6.125 -        if (newAction == null)
   6.126 -            throw new IllegalArgumentException("Null action");
   6.127 -        malformedInputAction = newAction;
   6.128 -        implOnMalformedInput(newAction);
   6.129 -        return this;
   6.130 -    }
   6.131 +//    public final CharsetEncoder onMalformedInput(CodingErrorAction newAction) {
   6.132 +//        if (newAction == null)
   6.133 +//            throw new IllegalArgumentException("Null action");
   6.134 +//        malformedInputAction = newAction;
   6.135 +//        implOnMalformedInput(newAction);
   6.136 +//        return this;
   6.137 +//    }
   6.138  
   6.139      /**
   6.140       * Reports a change to this encoder's malformed-input action.
   6.141 @@ -378,7 +376,7 @@
   6.142       * should be overridden by encoders that require notification of changes to
   6.143       * the malformed-input action.  </p>
   6.144       */
   6.145 -    protected void implOnMalformedInput(CodingErrorAction newAction) { }
   6.146 +//    protected void implOnMalformedInput(CodingErrorAction newAction) { }
   6.147  
   6.148      /**
   6.149       * Returns this encoder's current action for unmappable-character errors.
   6.150 @@ -387,9 +385,9 @@
   6.151       * @return The current unmappable-character action, which is never
   6.152       *         <tt>null</tt>
   6.153       */
   6.154 -    public CodingErrorAction unmappableCharacterAction() {
   6.155 -        return unmappableCharacterAction;
   6.156 -    }
   6.157 +//    public CodingErrorAction unmappableCharacterAction() {
   6.158 +//        return unmappableCharacterAction;
   6.159 +//    }
   6.160  
   6.161      /**
   6.162       * Changes this encoder's action for unmappable-character errors.
   6.163 @@ -404,15 +402,15 @@
   6.164       * @throws IllegalArgumentException
   6.165       *         If the precondition on the parameter does not hold
   6.166       */
   6.167 -    public final CharsetEncoder onUnmappableCharacter(CodingErrorAction
   6.168 -                                                      newAction)
   6.169 -    {
   6.170 -        if (newAction == null)
   6.171 -            throw new IllegalArgumentException("Null action");
   6.172 -        unmappableCharacterAction = newAction;
   6.173 -        implOnUnmappableCharacter(newAction);
   6.174 -        return this;
   6.175 -    }
   6.176 +//    public final CharsetEncoder onUnmappableCharacter(CodingErrorAction
   6.177 +//                                                      newAction)
   6.178 +//    {
   6.179 +//        if (newAction == null)
   6.180 +//            throw new IllegalArgumentException("Null action");
   6.181 +//        unmappableCharacterAction = newAction;
   6.182 +//        implOnUnmappableCharacter(newAction);
   6.183 +//        return this;
   6.184 +//    }
   6.185  
   6.186      /**
   6.187       * Reports a change to this encoder's unmappable-character action.
   6.188 @@ -421,7 +419,7 @@
   6.189       * should be overridden by encoders that require notification of changes to
   6.190       * the unmappable-character action.  </p>
   6.191       */
   6.192 -    protected void implOnUnmappableCharacter(CodingErrorAction newAction) { }
   6.193 +//    protected void implOnUnmappableCharacter(CodingErrorAction newAction) { }
   6.194  
   6.195      /**
   6.196       * Returns the average number of bytes that will be produced for each
   6.197 @@ -545,66 +543,66 @@
   6.198       *          If an invocation of the encodeLoop method threw
   6.199       *          an unexpected exception
   6.200       */
   6.201 -    public final CoderResult encode(CharBuffer in, ByteBuffer out,
   6.202 -                                    boolean endOfInput)
   6.203 -    {
   6.204 -        int newState = endOfInput ? ST_END : ST_CODING;
   6.205 -        if ((state != ST_RESET) && (state != ST_CODING)
   6.206 -            && !(endOfInput && (state == ST_END)))
   6.207 -            throwIllegalStateException(state, newState);
   6.208 -        state = newState;
   6.209 -
   6.210 -        for (;;) {
   6.211 -
   6.212 -            CoderResult cr;
   6.213 -            try {
   6.214 -                cr = encodeLoop(in, out);
   6.215 -            } catch (BufferUnderflowException x) {
   6.216 -                throw new CoderMalfunctionError(x);
   6.217 -            } catch (BufferOverflowException x) {
   6.218 -                throw new CoderMalfunctionError(x);
   6.219 -            }
   6.220 -
   6.221 -            if (cr.isOverflow())
   6.222 -                return cr;
   6.223 -
   6.224 -            if (cr.isUnderflow()) {
   6.225 -                if (endOfInput && in.hasRemaining()) {
   6.226 -                    cr = CoderResult.malformedForLength(in.remaining());
   6.227 -                    // Fall through to malformed-input case
   6.228 -                } else {
   6.229 -                    return cr;
   6.230 -                }
   6.231 -            }
   6.232 -
   6.233 -            CodingErrorAction action = null;
   6.234 -            if (cr.isMalformed())
   6.235 -                action = malformedInputAction;
   6.236 -            else if (cr.isUnmappable())
   6.237 -                action = unmappableCharacterAction;
   6.238 -            else
   6.239 -                assert false : cr.toString();
   6.240 -
   6.241 -            if (action == CodingErrorAction.REPORT)
   6.242 -                return cr;
   6.243 -
   6.244 -            if (action == CodingErrorAction.REPLACE) {
   6.245 -                if (out.remaining() < replacement.length)
   6.246 -                    return CoderResult.OVERFLOW;
   6.247 -                out.put(replacement);
   6.248 -            }
   6.249 -
   6.250 -            if ((action == CodingErrorAction.IGNORE)
   6.251 -                || (action == CodingErrorAction.REPLACE)) {
   6.252 -                // Skip erroneous input either way
   6.253 -                in.position(in.position() + cr.length());
   6.254 -                continue;
   6.255 -            }
   6.256 -
   6.257 -            assert false;
   6.258 -        }
   6.259 -
   6.260 -    }
   6.261 +//    public final CoderResult encode(CharBuffer in, ByteBuffer out,
   6.262 +//                                    boolean endOfInput)
   6.263 +//    {
   6.264 +//        int newState = endOfInput ? ST_END : ST_CODING;
   6.265 +//        if ((state != ST_RESET) && (state != ST_CODING)
   6.266 +//            && !(endOfInput && (state == ST_END)))
   6.267 +//            throwIllegalStateException(state, newState);
   6.268 +//        state = newState;
   6.269 +//
   6.270 +//        for (;;) {
   6.271 +//
   6.272 +//            CoderResult cr;
   6.273 +//            try {
   6.274 +//                cr = encodeLoop(in, out);
   6.275 +//            } catch (BufferUnderflowException x) {
   6.276 +//                throw new CoderMalfunctionError(x);
   6.277 +//            } catch (BufferOverflowException x) {
   6.278 +//                throw new CoderMalfunctionError(x);
   6.279 +//            }
   6.280 +//
   6.281 +//            if (cr.isOverflow())
   6.282 +//                return cr;
   6.283 +//
   6.284 +//            if (cr.isUnderflow()) {
   6.285 +//                if (endOfInput && in.hasRemaining()) {
   6.286 +//                    cr = CoderResult.malformedForLength(in.remaining());
   6.287 +//                    // Fall through to malformed-input case
   6.288 +//                } else {
   6.289 +//                    return cr;
   6.290 +//                }
   6.291 +//            }
   6.292 +//
   6.293 +//            CodingErrorAction action = null;
   6.294 +//            if (cr.isMalformed())
   6.295 +//                action = malformedInputAction;
   6.296 +//            else if (cr.isUnmappable())
   6.297 +//                action = unmappableCharacterAction;
   6.298 +//            else
   6.299 +//                assert false : cr.toString();
   6.300 +//
   6.301 +//            if (action == CodingErrorAction.REPORT)
   6.302 +//                return cr;
   6.303 +//
   6.304 +//            if (action == CodingErrorAction.REPLACE) {
   6.305 +//                if (out.remaining() < replacement.length)
   6.306 +//                    return CoderResult.OVERFLOW;
   6.307 +//                out.put(replacement);
   6.308 +//            }
   6.309 +//
   6.310 +//            if ((action == CodingErrorAction.IGNORE)
   6.311 +//                || (action == CodingErrorAction.REPLACE)) {
   6.312 +//                // Skip erroneous input either way
   6.313 +//                in.position(in.position() + cr.length());
   6.314 +//                continue;
   6.315 +//            }
   6.316 +//
   6.317 +//            assert false;
   6.318 +//        }
   6.319 +//
   6.320 +//    }
   6.321  
   6.322      /**
   6.323       * Flushes this encoder.
   6.324 @@ -645,19 +643,19 @@
   6.325       *          with a value of <tt>true</tt> for the <tt>endOfInput</tt>
   6.326       *          parameter
   6.327       */
   6.328 -    public final CoderResult flush(ByteBuffer out) {
   6.329 -        if (state == ST_END) {
   6.330 -            CoderResult cr = implFlush(out);
   6.331 -            if (cr.isUnderflow())
   6.332 -                state = ST_FLUSHED;
   6.333 -            return cr;
   6.334 -        }
   6.335 -
   6.336 -        if (state != ST_FLUSHED)
   6.337 -            throwIllegalStateException(state, ST_FLUSHED);
   6.338 -
   6.339 -        return CoderResult.UNDERFLOW; // Already flushed
   6.340 -    }
   6.341 +//    public final CoderResult flush(ByteBuffer out) {
   6.342 +//        if (state == ST_END) {
   6.343 +//            CoderResult cr = implFlush(out);
   6.344 +//            if (cr.isUnderflow())
   6.345 +//                state = ST_FLUSHED;
   6.346 +//            return cr;
   6.347 +//        }
   6.348 +//
   6.349 +//        if (state != ST_FLUSHED)
   6.350 +//            throwIllegalStateException(state, ST_FLUSHED);
   6.351 +//
   6.352 +//        return CoderResult.UNDERFLOW; // Already flushed
   6.353 +//    }
   6.354  
   6.355      /**
   6.356       * Flushes this encoder.
   6.357 @@ -673,9 +671,9 @@
   6.358       * @return  A coder-result object, either {@link CoderResult#UNDERFLOW} or
   6.359       *          {@link CoderResult#OVERFLOW}
   6.360       */
   6.361 -    protected CoderResult implFlush(ByteBuffer out) {
   6.362 -        return CoderResult.UNDERFLOW;
   6.363 -    }
   6.364 +//    protected CoderResult implFlush(ByteBuffer out) {
   6.365 +//        return CoderResult.UNDERFLOW;
   6.366 +//    }
   6.367  
   6.368      /**
   6.369       * Resets this encoder, clearing any internal state.
   6.370 @@ -736,8 +734,8 @@
   6.371       *
   6.372       * @return  A coder-result object describing the reason for termination
   6.373       */
   6.374 -    protected abstract CoderResult encodeLoop(CharBuffer in,
   6.375 -                                              ByteBuffer out);
   6.376 +//    protected abstract CoderResult encodeLoop(CharBuffer in,
   6.377 +//                                              ByteBuffer out);
   6.378  
   6.379      /**
   6.380       * Convenience method that encodes the remaining content of a single input
   6.381 @@ -770,36 +768,38 @@
   6.382       *          the current unmappable-character action is {@link
   6.383       *          CodingErrorAction#REPORT}
   6.384       */
   6.385 -    public final ByteBuffer encode(CharBuffer in)
   6.386 -        throws CharacterCodingException
   6.387 -    {
   6.388 -        int n = (int)(in.remaining() * averageBytesPerChar());
   6.389 -        ByteBuffer out = ByteBuffer.allocate(n);
   6.390 +//    public final ByteBuffer encode(CharBuffer in)
   6.391 +//        throws CharacterCodingException
   6.392 +//    {
   6.393 +//        int n = (int)(in.remaining() * averageBytesPerChar());
   6.394 +//        ByteBuffer out = ByteBuffer.allocate(n);
   6.395 +//
   6.396 +//        if ((n == 0) && (in.remaining() == 0))
   6.397 +//            return out;
   6.398 +//        reset();
   6.399 +//        for (;;) {
   6.400 +//            CoderResult cr = in.hasRemaining() ?
   6.401 +//                encode(in, out, true) : CoderResult.UNDERFLOW;
   6.402 +//            if (cr.isUnderflow())
   6.403 +//                cr = flush(out);
   6.404 +//
   6.405 +//            if (cr.isUnderflow())
   6.406 +//                break;
   6.407 +//            if (cr.isOverflow()) {
   6.408 +//                n = 2*n + 1;    // Ensure progress; n might be 0!
   6.409 +//                ByteBuffer o = ByteBuffer.allocate(n);
   6.410 +//                out.flip();
   6.411 +//                o.put(out);
   6.412 +//                out = o;
   6.413 +//                continue;
   6.414 +//            }
   6.415 +//            cr.throwException();
   6.416 +//        }
   6.417 +//        out.flip();
   6.418 +//        return out;
   6.419 +//    }
   6.420  
   6.421 -        if ((n == 0) && (in.remaining() == 0))
   6.422 -            return out;
   6.423 -        reset();
   6.424 -        for (;;) {
   6.425 -            CoderResult cr = in.hasRemaining() ?
   6.426 -                encode(in, out, true) : CoderResult.UNDERFLOW;
   6.427 -            if (cr.isUnderflow())
   6.428 -                cr = flush(out);
   6.429  
   6.430 -            if (cr.isUnderflow())
   6.431 -                break;
   6.432 -            if (cr.isOverflow()) {
   6.433 -                n = 2*n + 1;    // Ensure progress; n might be 0!
   6.434 -                ByteBuffer o = ByteBuffer.allocate(n);
   6.435 -                out.flip();
   6.436 -                o.put(out);
   6.437 -                out = o;
   6.438 -                continue;
   6.439 -            }
   6.440 -            cr.throwException();
   6.441 -        }
   6.442 -        out.flip();
   6.443 -        return out;
   6.444 -    }
   6.445  
   6.446  
   6.447  
   6.448 @@ -877,28 +877,26 @@
   6.449  
   6.450  
   6.451  
   6.452 -
   6.453 -
   6.454 -    private boolean canEncode(CharBuffer cb) {
   6.455 -        if (state == ST_FLUSHED)
   6.456 -            reset();
   6.457 -        else if (state != ST_RESET)
   6.458 -            throwIllegalStateException(state, ST_CODING);
   6.459 -        CodingErrorAction ma = malformedInputAction();
   6.460 -        CodingErrorAction ua = unmappableCharacterAction();
   6.461 -        try {
   6.462 -            onMalformedInput(CodingErrorAction.REPORT);
   6.463 -            onUnmappableCharacter(CodingErrorAction.REPORT);
   6.464 -            encode(cb);
   6.465 -        } catch (CharacterCodingException x) {
   6.466 -            return false;
   6.467 -        } finally {
   6.468 -            onMalformedInput(ma);
   6.469 -            onUnmappableCharacter(ua);
   6.470 -            reset();
   6.471 -        }
   6.472 -        return true;
   6.473 -    }
   6.474 +//    private boolean canEncode(CharBuffer cb) {
   6.475 +//        if (state == ST_FLUSHED)
   6.476 +//            reset();
   6.477 +//        else if (state != ST_RESET)
   6.478 +//            throwIllegalStateException(state, ST_CODING);
   6.479 +//        CodingErrorAction ma = malformedInputAction();
   6.480 +//        CodingErrorAction ua = unmappableCharacterAction();
   6.481 +//        try {
   6.482 +//            onMalformedInput(CodingErrorAction.REPORT);
   6.483 +//            onUnmappableCharacter(CodingErrorAction.REPORT);
   6.484 +//            encode(cb);
   6.485 +//        } catch (CharacterCodingException x) {
   6.486 +//            return false;
   6.487 +//        } finally {
   6.488 +//            onMalformedInput(ma);
   6.489 +//            onUnmappableCharacter(ua);
   6.490 +//            reset();
   6.491 +//        }
   6.492 +//        return true;
   6.493 +//    }
   6.494  
   6.495      /**
   6.496       * Tells whether or not this encoder can encode the given character.
   6.497 @@ -923,12 +921,12 @@
   6.498       * @throws  IllegalStateException
   6.499       *          If an encoding operation is already in progress
   6.500       */
   6.501 -    public boolean canEncode(char c) {
   6.502 -        CharBuffer cb = CharBuffer.allocate(1);
   6.503 -        cb.put(c);
   6.504 -        cb.flip();
   6.505 -        return canEncode(cb);
   6.506 -    }
   6.507 +//    public boolean canEncode(char c) {
   6.508 +//        CharBuffer cb = CharBuffer.allocate(1);
   6.509 +//        cb.put(c);
   6.510 +//        cb.flip();
   6.511 +//        return canEncode(cb);
   6.512 +//    }
   6.513  
   6.514      /**
   6.515       * Tells whether or not this encoder can encode the given character
   6.516 @@ -952,14 +950,14 @@
   6.517       * @throws  IllegalStateException
   6.518       *          If an encoding operation is already in progress
   6.519       */
   6.520 -    public boolean canEncode(CharSequence cs) {
   6.521 -        CharBuffer cb;
   6.522 -        if (cs instanceof CharBuffer)
   6.523 -            cb = ((CharBuffer)cs).duplicate();
   6.524 -        else
   6.525 -            cb = CharBuffer.wrap(cs.toString());
   6.526 -        return canEncode(cb);
   6.527 -    }
   6.528 +//    public boolean canEncode(CharSequence cs) {
   6.529 +//        CharBuffer cb;
   6.530 +//        if (cs instanceof CharBuffer)
   6.531 +//            cb = ((CharBuffer)cs).duplicate();
   6.532 +//        else
   6.533 +//            cb = CharBuffer.wrap(cs.toString());
   6.534 +//        return canEncode(cb);
   6.535 +//    }
   6.536  
   6.537  
   6.538