< prev index next >

src/share/vm/classfile/symbolTable.cpp

Print this page

        

*** 665,669 **** --- 665,700 ---- return dcmd->_dcmdparser.num_arguments(); } else { return 0; } } + + #ifndef PRODUCT + // Internal test of TempNewSymbol + void Test_TempNewSymbol() { + Thread* THREAD = Thread::current(); + Symbol* sym = SymbolTable::new_symbol("abc", CATCH); + TempNewSymbol ss = sym; + assert(ss->refcount() == 1, "only one abc"); + assert(ss->refcount() == sym->refcount(), "should match TempNewSymbol"); + + Symbol* sym1 = SymbolTable::new_symbol("efg", CATCH); + Symbol* sym2 = SymbolTable::new_symbol("hij", CATCH); + TempNewSymbol s1 = sym1; + TempNewSymbol s2 = sym2; + assert(s1->refcount() == 1, "one efg"); + assert(s2->refcount() == 1, "one hij"); + + // Assignment operator + s1 = s2; + assert(sym2->refcount() == 2, "should be two hij"); + assert(sym1->refcount() == 0, "should be no efg"); + + s1 = ss; // s1 is abc + assert(s1->refcount() == 2, "should be two abc (s1 and ss)"); + assert(sym2->refcount() == 1, "should only have one hij now (s2)"); + + TempNewSymbol s3; + s3 = SymbolTable::new_symbol("klm", CATCH); + assert(s3->refcount() == 1, "only one klm now"); + } + #endif // PRODUCT
< prev index next >