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

(spec) Constructor StringWriter(int) should document IAE when initialSize is negative

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 5.0
    • core-libs
    • b17
    • sparc
    • generic

        Filed By : JCK team
        JDK : java full version "1.5.0-b64"
        JCK : 1.5
        Failing Test [s] : None

      Problem description:
        The following constructor in the class java.io.StringWriter
            public StringWriter(int initialSize)
        can throw IllegalArgumentException when initialSize is negative,
        but don't document it.

        Minimized test:
        -- Test.java --
        import java.io.StringWriter;

        public class Test {

            public static void main(String[] args) {
                StringWriter obj = new StringWriter(-1);
                System.out.println("PASSED");
            }

        }
        -- End of Test.java --

        Minimized test result:
        ---
        $java -showversion Test
        java version "1.5.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
        Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)

        Exception in thread "main" java.lang.IllegalArgumentException: Negative buffer size
              at java.io.StringWriter.<init>(Unknown Source)
              at Test.main(Test.java:6)
        ---


            iris Iris Clark
            ygaevsky Yuri Gaevsky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: