1

I have a module

module-info.java

--

module my.module.with.cxf.generated.packages {
    requires slf4j.api;
    requires spring.context;
    requires java.persistence;
    requires spring.beans;
    requires org.apache.cxf.core;
    requires java.xml;
    requires java.xml.bind;
    opens cxf.generated.package.no.one to my.other.module
    opens cxf.generated.package.no.two to my.other.module 
    exports cxf.generated.package.no.one to my.other.module
    exports cxf.generated.package.no.two to my.other.module
}

--

and then my.other.module

module-info.java

--

module my.other.module {
     requires my.module.with.cxf.generated.packages
}

--

and I get that that

package cxf.generated.package.no.one is not visible

while compiling the code. What I'm doing wrong? How to fix this issue?

Additional information

IntelliJ IDEA 2020.3.1
Java 11
cxf-xjc-plugin 3.3.1
miroana
  • 494
  • 3
  • 22
  • good to learn that the order matters, but does `opens` not suffice for your use case? – Naman Jan 21 '21 at 03:46
  • if i put opens (and skipping exports I get 'the package [package name] is not visible') – miroana Jan 21 '21 at 04:12
  • alright, whatever does good for you, though not really sure of your use case to both export and opens packages to other modules. :) – Naman Jan 21 '21 at 04:21

1 Answers1

1

So, after trial and error I discovered that arranging packages so that exports go prior to opens yields a compiled result

module my.module.with.cxf.generated.packages {
    requires slf4j.api;
    requires spring.context;
    requires java.persistence;
    requires spring.beans;
    requires org.apache.cxf.core;
    requires java.xml;
    requires java.xml.bind;
    exports cxf.generated.package.no.one to my.other.module
    exports cxf.generated.package.no.two to my.other.module
    opens cxf.generated.package.no.one to my.other.module
    opens cxf.generated.package.no.two to my.other.module 
} 
miroana
  • 494
  • 3
  • 22