Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4853331

CharsetDecoder.implOnMalformedInput() has wrong default implementation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_8

      Description



      Name: auR10023 Date: 04/24/2003



      java.nio.charset.CharsetDecoder.implOnMalformedInput(CodingErrorAction)
      has wrong default implementation.
      Javadoc for this method says:
      ...
      The default implementation of this method does nothing.
      ...

      But invocation of the onMalformedInput() method (which according to the
      javadoc should invoke implOnMalformedInput()) change the state of the
      object.

      Here is the example:

      -------test.java---------

      import java.util.*;
      import java.nio.*;
      import java.nio.charset.*;

      public class test extends CharsetDecoder {
          public test(CharsetDecoder d) {
              super(d.charset(), d.averageCharsPerByte(), d.maxCharsPerByte());
          }

          protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
              return null;
          }

          public static void main(String [] args) {
          
              CharsetDecoder d = null;
          
              try {
                  d = Charset.forName("US-ASCII").newDecoder();
              } catch(Exception e) {
                  e.printStackTrace(System.out);
                  return;
              }

              CharsetDecoder dec = new test(d);
          
              System.out.println(dec.malformedInputAction());
              dec.onMalformedInput(CodingErrorAction.IGNORE);
              System.out.println(dec.malformedInputAction());
              dec.onMalformedInput(CodingErrorAction.REPLACE);
              System.out.println(dec.malformedInputAction());
          }
      }

      Here is the result
      #java -version

      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b04)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b04, mixed mode)

      #java test

      REPORT
      IGNORE
      REPLACE

      The same wrong behavior one can see with following methods of the
      CharsetDecoder:

      implOnUnmappableCharacter(), implReplaceWith()

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            mr Mark Reinhold
            Reporter:
            avusunw Avu Avu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: