The attached test case produces an invalid beans.xml with a duplicate <alternatives/> entry with the code:
'getOrCreate' is in fact always creating an alternatives entry, so the following beans.xml is produced in the example:
The produced beans.xml descriptor fails at deployment time with:
WELD-001203 <alternatives> can only be specified once, but appears multiple times: vfs:/content/demo.jar/META-INF/beans.xml@6
Also: Since there can only ever be one <alternatives/> block, it's not clear what the difference between getOrCreateAlternatives() and createAlternatives() is. Is the latter supposed to replace any existing block?
The API for managing alternatives is in Descriptors 2.0 is IMO difficult to use and understand. Issues with examples pending.