mirror of
https://github.com/corda/corda.git
synced 2025-01-01 10:46:46 +00:00
make Object.clone() work for arrays
This commit is contained in:
parent
1207989f72
commit
770e48c197
@ -101,10 +101,20 @@ Java_java_lang_Object_clone(Thread* t, jclass, jobject o)
|
|||||||
{
|
{
|
||||||
ENTER(t, Thread::ActiveState);
|
ENTER(t, Thread::ActiveState);
|
||||||
|
|
||||||
object clone = make(t, objectClass(t, *o));
|
object class_ = objectClass(t, *o);
|
||||||
memcpy(reinterpret_cast<void**>(clone) + 1,
|
unsigned size = baseSize(t, *o, class_) * BytesPerWord;
|
||||||
reinterpret_cast<void**>(*o) + 1,
|
object clone;
|
||||||
(baseSize(t, *o, objectClass(t, *o)) - 1) * BytesPerWord);
|
|
||||||
|
if (classArrayElementSize(t, class_)) {
|
||||||
|
clone = static_cast<object>(allocate(t, size));
|
||||||
|
memcpy(clone, *o, size);
|
||||||
|
} else {
|
||||||
|
clone = make(t, objectClass(t, *o));
|
||||||
|
memcpy(reinterpret_cast<void**>(clone) + 1,
|
||||||
|
reinterpret_cast<void**>(*o) + 1,
|
||||||
|
size - BytesPerWord);
|
||||||
|
}
|
||||||
|
|
||||||
return makeLocalReference(t, clone);
|
return makeLocalReference(t, clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user