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

fix: Generate a shadow ordinal field for Kotlin Enums #360

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

mrousavy
Copy link
Owner

Generates an added _ordinal field for every Kotlin Enum that can be accessed through fbjni.

Previously, we accessed ordinal, which should've been available in every Kotlin enum, but apparently some people had issues with this (@Szymon20000 & @shovel-kun) - maybe it got compiled out? Maybe it was an older Kotlin version? Maybe it got replaced with a ordinal() method for some reason? I don't know. I couldn't reproduce this bug.

Anyways; the smartest solution I can find that didn't degrade performance (calling ordinal() method thru JNI is slower than accessing a field) is that we just create a shadow-property on the Kotlin enum called _ordinal which mirrors whatever state the parent ordinal value or method has.

This can then be accessed directly from JNI as a field.

Copy link

vercel bot commented Nov 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
nitro-docs ⬜️ Skipped (Inspect) Nov 20, 2024 1:17pm

@mrousavy mrousavy merged commit 7a32224 into main Nov 20, 2024
13 checks passed
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

Successfully merging this pull request may close these issues.

1 participant