Incorrect result of compareTo between empty and non-empty strings

Current implementation of the Strings.compareTo() handles the case when
empty string compares to non-empty string in the wrong way.

This patch adds handler for such cases.

Change-Id: I35cc2cfd5141551d6da65748c44b59e64a3f8117
Signed-off-by: Alexei Zavjalov <alexei.zavjalov@intel.com>
diff --git a/runtime/arch/x86/quick_entrypoints_x86.S b/runtime/arch/x86/quick_entrypoints_x86.S
index b1f2275..8683a56 100644
--- a/runtime/arch/x86/quick_entrypoints_x86.S
+++ b/runtime/arch/x86/quick_entrypoints_x86.S
@@ -1307,8 +1307,10 @@
      *   esi: pointer to this string data
      *   edi: pointer to comp string data
      */
+    jecxz .Lkeep_length
     repe cmpsw                    // find nonmatching chars in [%esi] and [%edi], up to length %ecx
     jne .Lnot_equal
+.Lkeep_length:
     POP edi                       // pop callee save reg
     POP esi                       // pop callee save reg
     ret
diff --git a/test/021-string2/src/Main.java b/test/021-string2/src/Main.java
index 87e4baf..0239a3c 100644
--- a/test/021-string2/src/Main.java
+++ b/test/021-string2/src/Main.java
@@ -36,6 +36,10 @@
         Assert.assertTrue(test1.compareTo(test2) > 0);
         Assert.assertTrue(test2.compareTo(test1) < 0);
 
+        Assert.assertEquals("".compareTo(""), 0);
+        Assert.assertTrue(test.compareTo("") > 0);
+        Assert.assertTrue("".compareTo(test) < 0);
+
         /* compare string with a nonzero offset, in left/right side */
         Assert.assertEquals(test.compareTo(sub), 0);
         Assert.assertEquals(sub.compareTo(test), 0);