mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +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);
|
||||
|
||||
object clone = make(t, objectClass(t, *o));
|
||||
memcpy(reinterpret_cast<void**>(clone) + 1,
|
||||
reinterpret_cast<void**>(*o) + 1,
|
||||
(baseSize(t, *o, objectClass(t, *o)) - 1) * BytesPerWord);
|
||||
object class_ = objectClass(t, *o);
|
||||
unsigned size = baseSize(t, *o, class_) * BytesPerWord;
|
||||
object clone;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user