< prev index next >

src/share/vm/classfile/stringTable.cpp

Print this page
rev 10186 : [mq]: webrev.01
rev 10187 : [mq]: webrev.02

@@ -198,11 +198,10 @@
   ensure_string_alive(string);
 
   return string;
 }
 
-
 oop StringTable::intern(Handle string_or_null, jchar* name,
                         int len, TRAPS) {
   oop found_string = lookup_shared(name, len);
   if (found_string != NULL) {
     return found_string;

@@ -212,11 +211,13 @@
   int index = the_table()->hash_to_index(hashValue);
   found_string = the_table()->lookup_in_main_table(index, name, len, hashValue);
 
   // Found
   if (found_string != NULL) {
+    if (found_string != string_or_null()) {
     ensure_string_alive(found_string);
+    }
     return found_string;
   }
 
   debug_only(StableMemoryChecker smc(name, len * sizeof(name[0])));
   assert(!Universe::heap()->is_in_reserved(name),

@@ -247,11 +248,13 @@
     // Otherwise, add to symbol to table
     added_or_found = the_table()->basic_add(index, string, name, len,
                                   hashValue, CHECK_NULL);
   }
 
+  if (added_or_found != string()) { 
   ensure_string_alive(added_or_found);
+  }
 
   return added_or_found;
 }
 
 oop StringTable::intern(Symbol* symbol, TRAPS) {
< prev index next >