harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r967077 - in /harmony/enhanced/java/branches/java6: ./ classlib/ classlib/depends/libs/ classlib/modules/nio_char/src/main/java/java/nio/charset/ classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ cl...
Date Fri, 23 Jul 2010 12:43:34 GMT
Author: tellison
Date: Fri Jul 23 12:43:34 2010
New Revision: 967077

URL: http://svn.apache.org/viewvc?rev=967077&view=rev
Log:
Merging r967069 through r967074.

Modified:
    harmony/enhanced/java/branches/java6/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/depends/libs/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
    harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java
    harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
    harmony/enhanced/java/branches/java6/drlvm/   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/   (props changed)

Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 23 12:43:34 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-967068
+/harmony/enhanced/java/trunk:929253-967074
 /harmony/enhanced/trunk:476395-929252
 /incubator/harmony/enhanced/trunk:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 23 12:43:34 2010
@@ -1,7 +1,7 @@
 /harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
 /harmony/enhanced/classlib/trunk/working_classlib:884014-884286
 /harmony/enhanced/java/branches/mrh/classlib:935751-941490
-/harmony/enhanced/java/trunk/classlib:929253-967068
+/harmony/enhanced/java/trunk/classlib:929253-967074
 /harmony/enhanced/trunk/classlib:476395-929252
 /harmony/enhanced/trunk/working_classlib:476396-920147
 /incubator/harmony/enhanced/trunk/classlib:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 23 12:43:34 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-967068
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-967074
 /harmony/enhanced/trunk/classlib/depends/libs:476395-929252
 /incubator/harmony/enhanced/trunk/classlib/depends/libs:292550-476394

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java?rev=967077&r1=967076&r2=967077&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
Fri Jul 23 12:43:34 2010
@@ -88,7 +88,7 @@ public abstract class CharsetEncoder {
     /*
      * internal status consts
      */
-    private static final int INIT = 0;
+    private static final int READY = 0;
 
     private static final int ONGOING = 1;
 
@@ -96,6 +96,8 @@ public abstract class CharsetEncoder {
 
     private static final int FLUSH = 3;
 
+    private static final int INIT = 4;
+
     // the Charset which creates this encoder
     private Charset cs;
 
@@ -111,6 +113,9 @@ public abstract class CharsetEncoder {
     // internal status
     private int status;
 
+    // internal status indicates encode(CharBuffer) operation is finished
+    private boolean finished;
+
     // action for malformed input
     private CodingErrorAction malformAction;
 
@@ -217,10 +222,10 @@ public abstract class CharsetEncoder {
 
     // implementation of canEncode
     private boolean implCanEncode(CharBuffer cb) {
-        if (status == FLUSH) {
-            status = INIT;
+        if (status == FLUSH || status == INIT) {
+            status = READY;
         }
-        if (status != INIT) {
+        if (status != READY) {
             // niochar.0B=Another encoding process is ongoing\!
             throw new IllegalStateException(Messages.getString("niochar.0B")); //$NON-NLS-1$
         }
@@ -347,7 +352,8 @@ public abstract class CharsetEncoder {
             }
             break;
         }
-        status = FLUSH;
+        status = READY;
+        finished = true;
         return output;
     }
 
@@ -438,6 +444,12 @@ public abstract class CharsetEncoder {
      */
     public final CoderResult encode(CharBuffer in, ByteBuffer out,
             boolean endOfInput) {
+        //If the previous step is encode(CharBuffer), then no more input is needed
+        // thus endOfInput should not be false
+        if (status == READY && finished && !endOfInput) {
+            throw new IllegalStateException();
+        }
+
         if ((status == FLUSH) || (!endOfInput && status == END)) {
             throw new IllegalStateException();
         }
@@ -553,7 +565,7 @@ public abstract class CharsetEncoder {
      *             for the last boolean parameter.
      */
     public final CoderResult flush(ByteBuffer out) {
-        if (status != END && status != INIT) {
+        if (status != END && status != READY) {
             throw new IllegalStateException();
         }
         CoderResult result = implFlush(out);

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java?rev=967077&r1=967076&r2=967077&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java
Fri Jul 23 12:43:34 2010
@@ -290,20 +290,31 @@ public class ASCIICharsetEncoderTest ext
     public void testInternalState_Flushed() {
         CharsetEncoder newEncoder = cs.newEncoder();
         
-        //init -> flushed
-        {
-            ByteBuffer out = ByteBuffer.allocate(0x10);
-            newEncoder.flush(out);
-        }
-        
-        //reset - > flushed
+        // init -> flushed
+		{
+			ByteBuffer out = ByteBuffer.allocate(0x10);
+			try {
+				newEncoder.flush(out);
+				fail("Should throw IllegalStateException");
+			} catch (IllegalStateException e) {
+				//expected
+			}
+
+		}
+
+        // reset - > flushed
         {
             newEncoder.reset();
             CharBuffer in = CharBuffer.wrap("A");
             ByteBuffer out = ByteBuffer.allocate(0x10);
             newEncoder.encode(in, out, true);
             newEncoder.reset();
-            newEncoder.flush(out);
+            try {
+                newEncoder.flush(out);
+				fail("Should throw IllegalStateException");
+            } catch (IllegalStateException e) {
+                //expected
+            }
         }
         
         //encoding - > flushed
@@ -421,23 +432,14 @@ public class ASCIICharsetEncoderTest ext
             CharBuffer in = CharBuffer.wrap("A");
             newEncoder.encode(in);
             ByteBuffer out = ByteBuffer.allocate(0x10);
-            try {
-                newEncoder.encode(in, out, true);
-                fail("Should throw IllegalStateException");
-            } catch (IllegalStateException e) {
-                // expected
-            }
+            newEncoder.encode(in, out, true);
         }
+
         //Encode -> Flushed
         {
             CharBuffer in = CharBuffer.wrap("A");
             ByteBuffer out = newEncoder.encode(in);
-            try {
-                newEncoder.flush(out);
-                fail("Should throw IllegalStateException");
-            } catch (IllegalStateException e) {
-                // expected
-            }
+            newEncoder.flush(out);
         }
         
         //Encode - > encode

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java?rev=967077&r1=967076&r2=967077&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
Fri Jul 23 12:43:34 2010
@@ -296,6 +296,7 @@ public class CharsetEncoderTest extends 
 			encoder.flush(out);
 			fail("should throw IllegalStateException");
 		} catch (IllegalStateException e) {
+		    // Expected
 		}
 
 		// Illegal state: flush after encode with endOfInput is false
@@ -305,8 +306,22 @@ public class CharsetEncoderTest extends 
 			encoder.flush(out);
 			fail("should throw IllegalStateException");
 		} catch (IllegalStateException e) {
+		    // Expected
 		}
 	}
+	
+	public void testFlushAfterConstructing() {
+		ByteBuffer out = ByteBuffer.allocate(5);
+		
+		//Illegal state: flush after instance created
+		try {
+			encoder.flush(out);			
+			fail("should throw IllegalStateException");
+		} catch (IllegalStateException e) {
+			// Expected
+		}
+
+	}
 
 	// test illegal states for encode facade
 	public void testEncodeFacadeIllegalState() throws CharacterCodingException {

Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 23 12:43:34 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751-941490
-/harmony/enhanced/java/trunk/drlvm:929253-967068
+/harmony/enhanced/java/trunk/drlvm:929253-967074
 /harmony/enhanced/trunk/drlvm:476395-929252
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/drlvm:292550-476394

Propchange: harmony/enhanced/java/branches/java6/jdktools/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 23 12:43:34 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/jdktools:929253-967068
+/harmony/enhanced/java/trunk/jdktools:929253-967074
 /harmony/enhanced/jdktools/trunk:630107-925933
 /harmony/enhanced/trunk/jdktools:476395-929252
 /harmony/enhanced/trunk/working_jdktools:476396-920147



Mime
View raw message