-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat(java): expose core version in java engine layer #199
Conversation
@@ -141,6 +141,11 @@ public List<FeatureDef> listKnownToggles() throws YggdrasilError { | |||
return response.getValue(); | |||
} | |||
|
|||
public static String getCoreVersion() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're receiving a static pointer in this function so no need to clean up
@@ -31,6 +31,7 @@ pub type CompiledState = HashMap<String, CompiledToggle>; | |||
|
|||
pub const SUPPORTED_SPEC_VERSION: &str = "5.1.9"; | |||
const VARIANT_NORMALIZATION_SEED: u32 = 86028157; | |||
pub const CORE_VERSION: &str = env!("CARGO_PKG_VERSION"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bake the semver defined in the cargo toml file into a constant in the binary itself
Context, EngineState, EvalWarning, ExtendedVariantDef, ToggleDefinition, CORE_VERSION, | ||
}; | ||
|
||
static CORE_VERSION_CSTRING: std::sync::LazyLock<CString> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the expect
here is okay since this should only cause problems if this uses an escape character to inject a nul byte and this always a semver string which can't have escape characters.
For the Unrusted:
CStrings are heap allocated so we can't just make constants out of them. So we wrap this in a LazyLock, which sets the value the first time and thereafter just retrieves it. A singleton, if you will
For the Rusted:
Look ma, no once_cell
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
…o something horrible (#200)
…ods can be exposed and do memory management that should work on Java 18 and above (#198) * refactor(java): rework java engine so that static methods can be exposed cleanly * feat(java): expose core version in java engine layer (#199) * fix(java): force native encoding to utf-8 so windows doesn't set it to something horrible (#200)
…#197) * feat(java): expose list_known_features * refactor(java):separate resposibilities on java engine so static methods can be exposed and do memory management that should work on Java 18 and above (#198) * refactor(java): rework java engine so that static methods can be exposed cleanly * feat(java): expose core version in java engine layer (#199) * fix(java): force native encoding to utf-8 so windows doesn't set it to something horrible (#200)
Exposes the Yggdrasil version in the Java layer so we can always know what binary the Java engine is shipped with. Generally useful for other engines too