diff --git a/core/src/test/scala/spark/SizeEstimatorSuite.scala b/core/src/test/scala/spark/SizeEstimatorSuite.scala
index 17f366212b7829ff04946fbe6ab6bff10212ff00..bf3b2e1eeda439b315919cd00b4a0288b5f17edd 100644
--- a/core/src/test/scala/spark/SizeEstimatorSuite.scala
+++ b/core/src/test/scala/spark/SizeEstimatorSuite.scala
@@ -20,6 +20,15 @@ class DummyClass4(val d: DummyClass3) {
   val x: Int = 0
 }
 
+object DummyString {
+  def apply(str: String) : DummyString = new DummyString(str.toArray)
+}
+class DummyString(val arr: Array[Char]) {
+  override val hashCode: Int = 0
+  // JDK-7 has an extra hash32 field http://hg.openjdk.java.net/jdk7u/jdk7u6/jdk/rev/11987e85555f
+  @transient val hash32: Int = 0
+}
+
 class SizeEstimatorSuite
   extends FunSuite with BeforeAndAfterAll with PrivateMethodTester with ShouldMatchers {
 
@@ -50,10 +59,10 @@ class SizeEstimatorSuite
   // http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html
   // Work around to check for either.
   test("strings") {
-    SizeEstimator.estimate("") should (equal (48) or equal (40))
-    SizeEstimator.estimate("a") should (equal (56) or equal (48))
-    SizeEstimator.estimate("ab") should (equal (56) or equal (48))
-    SizeEstimator.estimate("abcdefgh") should (equal(64) or equal(56))
+    SizeEstimator.estimate(DummyString("")) should (equal (48) or equal (40))
+    SizeEstimator.estimate(DummyString("a")) should (equal (56) or equal (48))
+    SizeEstimator.estimate(DummyString("ab")) should (equal (56) or equal (48))
+    SizeEstimator.estimate(DummyString("abcdefgh")) should (equal(64) or equal(56))
   }
 
   test("primitive arrays") {
@@ -105,10 +114,10 @@ class SizeEstimatorSuite
     val initialize = PrivateMethod[Unit]('initialize)
     SizeEstimator invokePrivate initialize()
 
-    expect(40)(SizeEstimator.estimate(""))
-    expect(48)(SizeEstimator.estimate("a"))
-    expect(48)(SizeEstimator.estimate("ab"))
-    expect(56)(SizeEstimator.estimate("abcdefgh"))
+    expect(40)(SizeEstimator.estimate(DummyString("")))
+    expect(48)(SizeEstimator.estimate(DummyString("a")))
+    expect(48)(SizeEstimator.estimate(DummyString("ab")))
+    expect(56)(SizeEstimator.estimate(DummyString("abcdefgh")))
 
     resetOrClear("os.arch", arch)
   }
@@ -124,10 +133,10 @@ class SizeEstimatorSuite
     val initialize = PrivateMethod[Unit]('initialize)
     SizeEstimator invokePrivate initialize()
 
-    SizeEstimator.estimate("") should (equal (64) or equal (56))
-    SizeEstimator.estimate("a") should (equal (72) or equal (64))
-    SizeEstimator.estimate("ab") should (equal (72) or equal (64))
-    SizeEstimator.estimate("abcdefgh") should (equal (80) or equal (72))
+    SizeEstimator.estimate(DummyString("")) should (equal (64) or equal (56))
+    SizeEstimator.estimate(DummyString("a")) should (equal (72) or equal (64))
+    SizeEstimator.estimate(DummyString("ab")) should (equal (72) or equal (64))
+    SizeEstimator.estimate(DummyString("abcdefgh")) should (equal (80) or equal (72))
 
     resetOrClear("os.arch", arch)
     resetOrClear("spark.test.useCompressedOops", oops)