hotspot/src/share/vm/oops/arrayKlass.cpp
objArrayOop arrayKlass::allocate_arrayArray(int n, int length, TRAPS) {
{- -------------------------------------------
(1) もし指定された配列長(= length)が負値であれば, java_lang_NegativeArraySizeException.
---------------------------------------- -}
if (length < 0) {
THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
}
{- -------------------------------------------
(1) もし指定された配列長が最大長(= typeArrayKlass::max_length())を超えていれば, OutOfMemoryError.
---------------------------------------- -}
if (length > arrayOopDesc::max_array_length(T_ARRAY)) {
report_java_out_of_memory("Requested array size exceeds VM limit");
THROW_OOP_0(Universe::out_of_memory_error_array_size());
}
{- -------------------------------------------
(1) (変数宣言など)
---------------------------------------- -}
int size = objArrayOopDesc::object_size(length);
klassOop k = array_klass(n+dimension(), CHECK_0);
arrayKlassHandle ak (THREAD, k);
{- -------------------------------------------
(1) CollectedHeap::array_allocate() でメモリを確保し, リターンする.
---------------------------------------- -}
objArrayOop o =
(objArrayOop)CollectedHeap::array_allocate(ak, size, length, CHECK_0);
// initialization to NULL not necessary, area already cleared
return o;
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.