Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected offset for Unsafe.arrayIndexScale #618

Open
AliveDevil opened this issue Nov 6, 2024 · 0 comments
Open

Unexpected offset for Unsafe.arrayIndexScale #618

AliveDevil opened this issue Nov 6, 2024 · 0 comments

Comments

@AliveDevil
Copy link
Collaborator

A third-party component we are consuming uses Unsafe.arrayIndexScale(Object[].class), which returns unexpected values (I think 1, instead of 4 or 8).

Should this be amended to return IntPtr.Size for Object[]-arrays as well?

class Main {
    public static void main(String[] args)
    {
        System.out.println(sun.misc.Unsafe.ARRAY_OBJECT_BASE_OFFSET);
        System.out.println(sun.misc.Unsafe.ARRAY_OBJECT_INDEX_SCALE);
    }
}
Program stdout
16
4

Godbolt Sample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant