< prev index next > src/hotspot/share/oops/symbol.cpp
Print this page
assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
_hash_and_refcount = pack_hash_and_refcount(extract_hash(_hash_and_refcount), PERM_REFCOUNT);
}
#endif
+ bool Symbol::is_Q_signature() const {
+ int len = utf8_length();
+ return len > 2 && char_at(0) == JVM_SIGNATURE_PRIMITIVE_OBJECT && char_at(len - 1) == JVM_SIGNATURE_ENDCLASS;
+ }
+
+ bool Symbol::is_Q_array_signature() const {
+ int l = utf8_length();
+ if (l < 2 || char_at(0) != JVM_SIGNATURE_ARRAY || char_at(l - 1) != JVM_SIGNATURE_ENDCLASS) {
+ return false;
+ }
+ for (int i = 1; i < (l - 2); i++) {
+ char c = char_at(i);
+ if (c == JVM_SIGNATURE_PRIMITIVE_OBJECT) {
+ return true;
+ }
+ if (c != JVM_SIGNATURE_ARRAY) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ bool Symbol::is_Q_method_signature() const {
+ assert(SignatureVerifier::is_valid_method_signature(this), "must be");
+ int len = utf8_length();
+ if (len > 4 && char_at(0) == JVM_SIGNATURE_FUNC) {
+ for (int i=1; i<len-3; i++) { // Must end with ")Qx;", where x is at least one character or more.
+ if (char_at(i) == JVM_SIGNATURE_ENDFUNC && char_at(i+1) == JVM_SIGNATURE_PRIMITIVE_OBJECT) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ Symbol* Symbol::fundamental_name(TRAPS) {
+ if ((char_at(0) == JVM_SIGNATURE_PRIMITIVE_OBJECT || char_at(0) == JVM_SIGNATURE_CLASS) && ends_with(JVM_SIGNATURE_ENDCLASS)) {
+ return SymbolTable::new_symbol(this, 1, utf8_length() - 1);
+ } else {
+ // reference count is incremented to be consistent with the behavior with
+ // the SymbolTable::new_symbol() call above
+ this->increment_refcount();
+ return this;
+ }
+ }
+
+ bool Symbol::is_same_fundamental_type(Symbol* s) const {
+ if (this == s) return true;
+ if (utf8_length() < 3) return false;
+ int offset1, offset2, len;
+ if (ends_with(JVM_SIGNATURE_ENDCLASS)) {
+ if (char_at(0) != JVM_SIGNATURE_PRIMITIVE_OBJECT && char_at(0) != JVM_SIGNATURE_CLASS) return false;
+ offset1 = 1;
+ len = utf8_length() - 2;
+ } else {
+ offset1 = 0;
+ len = utf8_length();
+ }
+ if (ends_with(JVM_SIGNATURE_ENDCLASS)) {
+ if (s->char_at(0) != JVM_SIGNATURE_PRIMITIVE_OBJECT && s->char_at(0) != JVM_SIGNATURE_CLASS) return false;
+ offset2 = 1;
+ } else {
+ offset2 = 0;
+ }
+ if ((offset2 + len) > s->utf8_length()) return false;
+ if ((utf8_length() - offset1 * 2) != (s->utf8_length() - offset2 * 2))
+ return false;
+ int l = len;
+ while (l-- > 0) {
+ if (char_at(offset1 + l) != s->char_at(offset2 + l))
+ return false;
+ }
+ return true;
+ }
+
// ------------------------------------------------------------------
// Symbol::index_of
//
// Test if we have the give substring at or after the i-th char of this
// symbol's utf8 bytes.
jbyte* bytes = (jbyte*) s->bytes();
return os::is_readable_range(bytes, bytes + len);
}
+ void Symbol::print_Qvalue_on(outputStream* st) const {
+ st->print("'Q");
+ for (int i = 0; i < utf8_length(); i++) {
+ st->print("%c", char_at(i));
+ }
+ st->print(";'");
+ }
+
// SymbolTable prints this in its statistics
NOT_PRODUCT(size_t Symbol::_total_count = 0;)
#ifndef PRODUCT
bool Symbol::is_valid_id(vmSymbolID vm_symbol_id) {
< prev index next >