Adjust code to provide basic Android support #1869
Open
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.
The following code adds JAXB marshalling and unmarshalling support for Android Java runtime, as ART is implemented differently than a standard Openjdk implementation.
StackWalker is present in Android API since API Level 34 (Android 14) which approximately 50% of devices currently supports, which is why I have decided to provide an alternative implementation for older API levels (based from the previous Jakarta code before bumping to Jdk11)
Android does not provide any implementation for java.awt.*, which is why I check during runtime if this classes are present,
Android also does not provide a StaX implementation, which is why I added an extra StaX dependency found online, I belive if there is any interest to remove StaX dependency for Android it whould be done on another PR.
Android also, does not support Java 9+ modules, according to the previous code of MUtils the function was empty before switching to Jdk9, which is where I replicate such behaviour.
All maven tests passes.
Relevant code that was tested under Android:
without this edits, JAXBContext.newInstance would crash, while on Openjdk it would work as intended.
Extra environment information for replicating marshaller/unmarshaller tests:
Dependencies added: