mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
fix sun.misc.Unsafe.arrayIndexScale implementation
The original implementation was based on the assumption that the passed class would be the array element type, whereas it is actually the array type itself.
This commit is contained in:
parent
6507150246
commit
4b0bbd85e8
@ -2665,24 +2665,21 @@ extern "C" JNIEXPORT int64_t JNICALL
|
||||
Avian_sun_misc_Unsafe_arrayIndexScale
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object c = jclassVmClass(t, reinterpret_cast<object>(arguments[1]));
|
||||
|
||||
if (classVmFlags(t, c) & PrimitiveFlag) {
|
||||
const char* name = reinterpret_cast<char*>
|
||||
(&byteArrayBody(t, local::getClassName(t, c), 0));
|
||||
|
||||
switch (*name) {
|
||||
case 'b': return 1;
|
||||
case 's':
|
||||
case 'c': return 2;
|
||||
case 'l':
|
||||
case 'd': return 8;
|
||||
case 'i':
|
||||
case 'f': return 4;
|
||||
default: abort(t);
|
||||
}
|
||||
} else {
|
||||
return BytesPerWord;
|
||||
switch (byteArrayBody
|
||||
(t, className
|
||||
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[1]))), 1))
|
||||
{
|
||||
case 'Z':
|
||||
case 'B': return 1;
|
||||
case 'S':
|
||||
case 'C': return 2;
|
||||
case 'I':
|
||||
case 'F': return 4;
|
||||
case 'J':
|
||||
case 'D': return 8;
|
||||
case '[':
|
||||
case 'L': return BytesPerWord;
|
||||
default: abort(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user