* fixed: GlobalValueEnumeration crash #567 #571
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
issue #567.
not exact issue but same problem.
In general native-to-Java enum mapping is fragile in RoboVM as most likely app will crash if set of enum items in app differs from one available in system:
case 1: global value is not available on target os
(case as described in #567) -- fails with
UnsatisfiedLinkError
. Happens when app was built for newer API version but run on old device. As result global value is not available in the binary.Root case: native to java marshaller code looks like bellow
valueOf
:If entry is missing -- v.value() will cause
UnsatisfiedLinkError
the fix:
code to be added to check if
v.isAvailable()
before doingv.value().equals(value)
case 2: value is unknown for application.
Happens when marshalling value returned by system API and it is not known for application. Happens when old app runs on new OS. In this case same
valueOf
marshaller will not find the value in knownvalues
list and throwIllegalArgumentException("No constant with value")
.the fix:
It is against enum concept (e.g. it has to be fixed runtime but
GlobalValueEnumeration
is not a true enum) - the fix is to dynamically create new entry of enumeration item and add it tovalues
.discussion
This PR updates only
AVMetadataObjectType
but in general all bindings forGlobalValueEnumeration
to be updated