zeroc-ice / ice

All-in-one solution for creating networked applications with RPC, pub/sub, server deployment, and more.
https://zeroc.com
GNU General Public License v2.0
2k stars 592 forks source link

Add support for Java modules #286

Open bernardnormier opened 5 years ago

bernardnormier commented 5 years ago

Ice for Java should support modules (introduced in Java 9): https://www.oracle.com/corporate/features/understanding-java-9-modules.html

pepone commented 5 years ago

I added support to build modular JARs, when using Java 9 or greater, the JARs should work with Java 8 too.

For now Ice, IceBox, IceSSL, IceBT, IceDiscovery and IceLocatorDiscovery have been converted to modular JARs, for other JARs we have to wait until #425 has been fixed.

https://github.com/zeroc-ice/ice/commit/777bff38b800a3d49457cf04f818d003dfacdf6c

One issue I see is that if you try to use --module-path with the ice/java/lib directory you get errors like

 error: duplicate module on application module path
  module in icestorm

That is related to having both sources, documentation and regular JARs in the same directory.

pepone commented 5 years ago

Moved the javadoc and sources JARs to doc directory to avoid issues when adding ice/java/lib to the --module-path

but that isn't enough having the proguard icegridgui.jar in the module-path also cause problems

error: the unnamed module reads package com.zeroc.Ice from both icegridgui and com.zeroc.ice
error: the unnamed module reads package com.zeroc.Ice.Instrumentation from both icegridgui and com.zeroc.ice
error: the unnamed module reads package com.zeroc.IceMX from both icegridgui and com.zeroc.ice

And having the JARs that contain IceMX split package in the module-path can also cause problems, because Java will make them part of the unnamed module resulting in errors like

error: the unnamed module reads package com.zeroc.IceMX from both glacier2 and com.zeroc.ice
error: the unnamed module reads package com.zeroc.IceMX from both glacier2 and icestorm
error: module icestorm reads package com.zeroc.IceMX from both glacier2 and icestorm
error: module icestorm reads package com.zeroc.IceMX from both glacier2 and com.zeroc.ice

I think we should just have the required module JARs added to the --module-path and not the library dir.