/* * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
int java_lang_String::length(oop java_string, typeArrayOop value) {
assert(_initialized, "Must be initialized");
assert(is_instance(java_string), "must be java_string");
assert(value_equals(value, java_lang_String::value(java_string)), "value must be equal to java_lang_String::value(java_string)"); if (value == NULL) { return 0;
} int arr_length = value->length(); if (!is_latin1(java_string)) {
assert((arr_length & 1) == 0, "should be even for UTF16 string");
arr_length >>= 1; // convert number of bytes to number of elements
} return arr_length;
}
int java_lang_String::length(oop java_string) {
assert(_initialized, "Must be initialized");
assert(is_instance(java_string), "must be java_string");
typeArrayOop value = java_lang_String::value_no_keepalive(java_string); return length(java_string, value);
}
inline Klass* java_lang_Class::as_Klass(oop java_class) { //%note memory_2
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
Klass* k = ((Klass*)java_class->metadata_field(_klass_offset));
assert(k == NULL || k->is_klass(), "type check"); return k;
}
inlinebool java_lang_Class::is_primitive(oop java_class) { // should assert: //assert(java_lang_Class::is_instance(java_class), "must be a Class object"); bool is_primitive = (java_class->metadata_field(_klass_offset) == NULL);
#ifdef ASSERT if (is_primitive) {
Klass* k = ((Klass*)java_class->metadata_field(_array_klass_offset));
assert(k == NULL || is_java_primitive(ArrayKlass::cast(k)->element_type()), "Should be either the T_VOID primitive or a java primitive");
} #endif
return is_primitive;
}
inline size_t java_lang_Class::oop_size(oop java_class) {
assert(_oop_size_offset != 0, "must be set"); int size = java_class->int_field(_oop_size_offset);
assert(size > 0, "Oop size must be greater than zero, not %d", size); return size;
}
inlineint Backtrace::merge_bci_and_version(int bci, int version) { // only store u2 for version, checking for overflow. if (version > USHRT_MAX || version < 0) version = USHRT_MAX;
assert((jushort)bci == bci, "bci should be short"); return build_int_from_shorts(version, bci);
}
inlineint Backtrace::merge_mid_and_cpref(int mid, int cpref) { // only store u2 for mid and cpref, checking for overflow.
assert((jushort)mid == mid, "mid should be short");
assert((jushort)cpref == cpref, "cpref should be short"); return build_int_from_shorts(cpref, mid);
}
inlineint Backtrace::get_line_number(Method* method, int bci) { int line_number = 0; if (method->is_native()) { // Negative value different from -1 below, enabling Java code in // class java.lang.StackTraceElement to distinguish "native" from // "no LineNumberTable". JDK tests for -2.
line_number = -2;
} else { // Returns -1 if no LineNumberTable, and otherwise actual line number
line_number = method->line_number_from_bci(bci);
} return line_number;
}
inline Symbol* Backtrace::get_source_file_name(InstanceKlass* holder, int version) { // RedefineClasses() currently permits redefine operations to // happen in parallel using a "last one wins" philosophy. That // spec laxness allows the constant pool entry associated with // the source_file_name_index for any older constant pool version // to be unstable so we shouldn't try to use it. if (holder->constants()->version() != version) { return NULL;
} else { return holder->source_file_name();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.