24
#include "precompiled.hpp"
25
#include "classfile/symbolTable.hpp"
26
#include "memory/resourceArea.hpp"
27
#include "runtime/interfaceSupport.inline.hpp"
28
#include "runtime/signature.hpp"
29
#include "threadHelper.inline.hpp"
30
#include "unittest.hpp"
32
TEST_VM(SignatureStream, check_refcount) {
34
JavaThread* THREAD = JavaThread::current();
36
ThreadInVMfromNative ThreadInVMfromNative(THREAD);
38
ResourceMark rm(THREAD);
40
Symbol* foo = SymbolTable::new_symbol("Foo");
41
int r1 = foo->refcount();
45
Symbol* methodSig = SymbolTable::new_symbol("LFoo;");
46
SignatureStream ss(methodSig, false);
47
Symbol* sym = ss.as_symbol();
48
ASSERT_EQ(sym, foo) << "found symbol should be Foo: " << sym->as_C_string();
50
ASSERT_EQ(foo->refcount(), r1 + 1) << "refcount should be incremented";
52
ASSERT_TRUE(!ss.is_done())
53
<< "stream parsing should not be marked as done until"
54
<<" ss.next() called after the last symbol";
57
ASSERT_TRUE(ss.is_done()) << "stream parsing should be marked as done";
60
ASSERT_EQ(foo->refcount(), r1) << "refcount should have decremented";
65
Symbol* integer = SymbolTable::new_symbol("java/lang/Integer");
66
ASSERT_TRUE(integer->is_permanent()) << "java/lang/Integer must be permanent";
68
Symbol* methodSig = SymbolTable::new_symbol("(LFoo;)Ljava/lang/Integer;");
69
SignatureStream ss(methodSig);
70
Symbol* sym = ss.as_symbol();
71
ASSERT_EQ(sym, foo) << "found symbol should be Foo: " << sym->as_C_string();
73
ASSERT_EQ(foo->refcount(), r1 + 1) << "refcount should be incremented";
77
ASSERT_EQ(sym, integer) << "found symbol should be java/lang/Integer";
79
ASSERT_TRUE(!ss.is_done())
80
<< "stream parsing should not be marked as done until"
81
<<" ss.next() called after the last symbol";
84
ASSERT_TRUE(ss.is_done()) << "stream parsing should be marked as done";
87
ASSERT_EQ(foo->refcount(), r1) << "refcount should have decremented";