How does OSGi application work on Java 9?

Pavel_K :

I am trying to understand how OSGi application works in Java 9 assuming that OSGi bundle is not JPMS module (as far as I know there is still no solution that OSGi bundle could be at the same time JPMS module for production). And I have several questions:

  1. Do I understand right that all OSGi application will be one unnamed module?
  2. If #1 yes, then how does Bundle.update() works? Is bundle reloaded to unnamed module?

If I understand everything wrong, please explain main principles.

Neil Bartlett :

Java SE 9 guarantees continued compatibility for all applications and libraries that stick to the standard Java SE libraries.

OSGi only uses published Java SE APIs and therefore will continue to work unchanged on Java 9. It does not at this time interact with JPMS modules, which will be the case for all your other Java software. At some point the OSGi expert groups will likely produce a specification for interoperability between JPMS modules and OSGi bundles, but that is for the future.

To answer your specific questions:

  1. Yes, OSGi bundles will be mapped to one or more "unnamed" modules in JPMS terms. Again, this is exactly how Java 9 retains backwards compatibility for all your other Java applications.

  2. Bundle update works the same way it has worked for 18 years. The classloader provided for the bundle is disposed and a new classloader created to load the updates classes.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=431597&siteId=1