1

I have some misunderstanding of OSGI fragment,

Suppose I have deployed a bundle "B" with two classes "com.company.C1" and "com.company.C2" where C1 use C2. And then, I deployed a fragment "F" for the host bundle "B" where F contains only one class "com.company.C2" (with a little change in the code of the first class)

Now, if the class "com.company.C1" is being executed, which class (file) "com.company.C2" will be used, from "B" or from "F" ?

Can the presence of the same class C2 twice in the same class-loader cause runtime errors (same version & differents versions)?

Jugu
  • 787
  • 1
  • 9
  • 23

1 Answers1

5

Read chapter "3.9.4 Overall Search Order" of OSGi Core specification and everything will be clear.

In short: The classes in the bundle are checked first and than the fragment bundle. If you have a class in the bundle and in the fragment bundle, the one in the fragment bundle will never be used.

Balazs Zsoldos
  • 6,036
  • 2
  • 23
  • 31
  • See also section "3.9.1 Bundle Class Path" which shows an example of how one can open up "space" in the host bundle for a fragment to replace classes in the host bundle. – BJ Hargrave Sep 27 '16 at 16:31