diff src/share/vm/oops/oop.cpp @ 10155:f258c5828eb8

8011773: Some tests on Interned String crashed JVM with OOM Summary: Instead of terminating the VM, throw OutOfMemoryError exceptions. Reviewed-by: coleenp, dholmes
author hseigel
date Mon, 29 Apr 2013 16:13:57 -0400
parents f34d701e952e
children 746b070f5022
line wrap: on
line diff
--- a/src/share/vm/oops/oop.cpp	Fri Apr 26 08:40:24 2013 -0700
+++ b/src/share/vm/oops/oop.cpp	Mon Apr 29 16:13:57 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -103,11 +103,17 @@
 
 // When String table needs to rehash
 unsigned int oopDesc::new_hash(jint seed) {
+  EXCEPTION_MARK;
   ResourceMark rm;
   int length;
-  jchar* chars = java_lang_String::as_unicode_string(this, length);
-  // Use alternate hashing algorithm on the string
-  return AltHashing::murmur3_32(seed, chars, length);
+  jchar* chars = java_lang_String::as_unicode_string(this, length, THREAD);
+  if (chars != NULL) {
+    // Use alternate hashing algorithm on the string
+    return AltHashing::murmur3_32(seed, chars, length);
+  } else {
+    vm_exit_out_of_memory(length, "unable to create Unicode strings for String table rehash");
+    return 0;
+  }
 }
 
 VerifyOopClosure VerifyOopClosure::verify_oop;