MobiVM / robovm

Ahead of time compiler for JVM bytecode targetting iOS, Mac OSX and Linux
https://mobivm.github.io
942 stars 132 forks source link

* fixed: strict rules for elements in lists inside robovm.xml #730

Closed dkimitsa closed 10 months ago

dkimitsa commented 1 year ago

(also includes changes from https://github.com/MobiVM/robovm/pull/729)

NP

SimpleXML is quite old and outdated. And it would be nice to switch to another XML bindings such as Jackson/JAXP but all of them doesn't allow xml string mutation required for property values substitutions (e.g. <executableName>${app.executable}</executableName>)

Root case:

SimpleXML issue: it allows unexpected tags to be present while parsing list, this caused side effect like empty text tags or null objects inserted into the list, for example

   <frameworks>
      <wrong><framework>aaaa</framework><wrong/>
   </>

would result in (null, "aaaa") in list (beside the fact that structure is wrong)

The fix

General approach for a workaround is change List field type to custom POJO and make its serialization strict: E.g. instead of

 @ElementList(required = false, entry = "framework")
 private ArrayList<String> frameworks;

list wrapper class to be used:

 https://github.com/element(required = false)
 private FrameworksList frameworks;

list wrapper class expected to be @root with strict = true, so unexpected tags will cause exception