ReturnOop JarFileParser::get_parser_from_cache(const JvmPathChar* jar_file_name1, TypeArray *jar_file_name2) { // Count trailing zero as well const int name_bytes = jar_file_name1 ? (fn_strlen(jar_file_name1)+1) * sizeof(JvmPathChar) : jar_file_name2->length(); const int max = MAX_CACHED_PARSERS < MaxCachedJarParsers ? MAX_CACHED_PARSERS : MaxCachedJarParsers; #if ENABLE_ISOLATES const char current_task_id = TaskContext::current_task_id(); #endif for( int i=0; i < max; i++ ) { const int ref = _cached_parsers[i]; if (ref >= 0) { #if ENABLE_ISOLATES const char task_id = ObjectHeap::get_global_reference_owner(ref); if( task_id != current_task_id ) { // Don't share cached JarFileParser across task ID. See // JarFileParser.hpp for why. continue; } #endif JarFileParser::Raw parser = ObjectHeap::get_global_ref_object(ref); if (parser.not_null()) { TypeArray::Raw stored_name = parser().pathname(); JvmPathChar *data = (JvmPathChar*)stored_name().byte_base_address(); bool match; if (jar_file_name1) { match = stored_name().length() == name_bytes && jvm_memcmp(data, jar_file_name1, name_bytes) == 0; } else { match = jar_file_name2->equals(&stored_name) || (stored_name().length() == name_bytes && jvm_memcmp(data, jar_file_name2->byte_base_address(), name_bytes) == 0); } if (match) { if (TraceJarCache) { TTY_TRACE(("JAR: parser cache hit: ")); for (int n=0; n <= name_bytes; n++) { TTY_TRACE(("%c", (char)data[n])); } TTY_TRACE_CR(("")); } // Found a match parser().set_timestamp(++_timestamp); return parser; } } } } return NULL; }
bool matches(utf8 s, int len) { if (len != _length) { return false; } else { return jvm_memcmp(s, utf8_data(), len) == 0; } }
jboolean ClassMatchModifier::class_match(DebuggerEvent *d_event) { UsingFastOops fast_oops; JavaClass::Fast clazz = JavaDebugger::get_object_by_id(d_event->clazz_id()); TypeSymbol::Fast class_name = clazz().name(); Symbol::Fast mod_name = class_match_name(); if (mod_name.is_null() || class_name.is_null()) return true; if (clazz().is_obj_array_class()) { juint klass_index = class_name().decode_ushort_at(0); JavaClass::Raw klass = Universe::class_from_id(klass_index); ObjArrayClass::Raw oac = klass.obj(); klass = oac().element_class(); class_name = klass().name(); } else if (clazz().is_type_array_class()) { // just a basic type array, no match here. return false; } // class names in the VM are not necessarily stored with the current OS // file separator character, Win32 can use either type of slash if (mod_name().byte_at(0) == '*' || mod_name().byte_at(mod_name().length()-1) == '*') { // We have a wildcard match. int complen = mod_name().length() - 1; int req_start = class_name().length() - complen; int mod_start = 0; if (req_start < 0) { return false; } else { if (mod_name().byte_at(0) == '*') { // suffix match // just compare the end of classname mod_start = 1; // point to just past the '*' } else { req_start = 0; // prefix match } return (jvm_memcmp(mod_name().utf8_data() + mod_start, class_name().utf8_data() + req_start, complen) == 0); } } else { // not a suffix/prefix match so just compare the two. return mod_name().matches(&class_name()); } }
bool JarFileParser::match(const char *suffix, const char *name, int name_len) { int suffix_len = jvm_strlen(suffix); int skip = name_len - suffix_len; if (skip <= 0) { // i.e., the suffix ".class" matches with the name "x.class", but not with // the name ".class" return false; } name += skip; if (jvm_memcmp(name, suffix, suffix_len) == 0) { return true; } else { return false; } }
bool String::matches(String *that_string) { if (this->count() != that_string->count()) { return false; } TypeArray::Raw this_array = this->value(); TypeArray::Raw that_array = that_string->value(); address this_base = this_array().base_address(); address that_base = that_array().base_address(); this_base += sizeof(jchar) * this->offset(); that_base += sizeof(jchar) * that_string->offset(); if (jvm_memcmp(this_base, that_base, count() * 2) == 0) { return true; } else { return false; } }
// If this FileDecoder is associated with a JAR file, make sure when // we try to use the file handle, we always have an active // JarFileParser. See JarFileParser.cpp header for the gory details. void FileDecoder::guarantee_jar_file_handle() { #ifdef AZZERT if (jar_file_name() != NULL) { int seen = false; ForAllHandles (oop) { if (oop->not_null() && oop->is_jar_file_parser()) { JarFileParser::Raw parser = oop->obj(); TypeArray::Raw name1 = parser().pathname(); TypeArray::Raw name2 = jar_file_name(); int len1 = name1().length(); int len2 = name2().length(); void *base1 = name1().base_address(); void *base2 = name2().base_address(); GUARANTEE(len1 == len2 && jvm_memcmp(base1, base2, len1) == 0, "Only one active JarFileParser at any time"); seen = true; } } GUARANTEE(seen, "JarFileParser associated with this FileDecoder must be " "active on C stack"); }
bool SymbolDesc::matches(SymbolDesc* other_symbol) { if (_length != other_symbol->_length) { return false; } return jvm_memcmp(utf8_data(), other_symbol->utf8_data(), _length) == 0; }
int memcmp_from_interpreter(const void *s1, const void *s2, size_t n) { return jvm_memcmp(s1, s2, n); }