您可以在此处下载OpenJdk源代码。
在该文件夹中,
jdksrcshare您可以获取源代码。
jdksrcsharenative是使用c和c ++编写的natice方法。
jdksrclinux
Linux的源代码。jdksrcwindows
Windows的源。jdksrcsolaris
索拉里斯的来源。jdsrcshare
共同来源。
例如:System.arrayCopy();
int文件
hotspotsrcsharevmoopsobjArrayKlass.cpp行168:
void objArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS) {assert(s->is_objArray(), "must be obj array");if (!d->is_objArray()) { THROW(vmSymbols::java_lang_ArrayStoreException());}// Check is all offsets and lengths are non negativeif (src_pos < 0 || dst_pos < 0 || length < 0) { THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());}// Check if the ranges are validif ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) { THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());}// Special case. Boundary cases must be checked first// This allows the following call: copy_array(s, s.length(), d.length(), 0).// This is correct, since the position is supposed to be an 'in between point', i.e., s.length(),// points to the right of the last element.if (length==0) { return;}if (UseCompressedOops) { narrowOop* const src = objArrayOop(s)->obj_at_addr<narrowOop>(src_pos); narrowOop* const dst = objArrayOop(d)->obj_at_addr<narrowOop>(dst_pos); do_copy<narrowOop>(s, src, d, dst, length, CHECK);} else { oop* const src = objArrayOop(s)->obj_at_addr<oop>(src_pos); oop* const dst = objArrayOop(d)->obj_at_addr<oop>(dst_pos); do_copy<oop> (s, src, d, dst, length, CHECK); }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)