Closed Draspax closed 5 years ago
Fix for issue described in https://github.com/wwrd/ikvm8/issues/4
4 is better than 1, definitely, and the submission is worth accepting.
I still concerned as this is about a reference size which may be 4 bytes but may be 8. It depends on what platform/architecture source code compiles and runs.
So, someone some day may hit an issue with a memory corruption because their references will be 8 bytes long.
Unsafe.arrayIndexScale(Object[].class) == 4 in java even in 64 bit because HotSpot is using compressed ordinary object pointers The VM option -XX:+UseCompressedOops is used by default. But if you run arrayIndexScale with -XX:-UseCompressedOops (turned off), it returns 8.
I have no idea of how to get the correct number from Unsafe. I even think it is not possible to do in Java. I don't also know how it really matters for IKVM usage.
I am not sure whether IKVM even supports CompressedOops, as it maps Java objects to .NET objects under the hood.
My guess is that IntPtr.Size from .NET API would be the correct size.
When an object array is passed to arrayIndexScale it should return 4.