I was just wondering how does the container select which package to load a class if the same package is exported multiple times by different bundles.
Given the following what is true. Note the list also contains the actual order the bundles were deployed.
- package.x version 1 (A)
- package.x version 2 (B)
- package.x version 3 (C)
If a 4th bundle is added and it needs ‘package.x.SomeClass’ 1-2 from where will it be selected?
- Does it randomly pick from either A or B?
- Does it fail to deploy B because of the clash?
- Does it pick A because it was first?
Do all containers do the same thing or is the behaviour different between the available popular packages?
The framework will pick either A or B. It does not do so “randomly”, but the heuristics are complicated and it is better not to attempt to predict what will happen. Also the behaviour in this case is not specified and is subject to differences between OSGi framework implementations.