I wanted to use the Jython library in my Java application because I need my app to use Python. In the maven pom.xml file I added the Jython dependency:
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.7.2</version>
<scope>compile</scope>
</dependency>
I observed that without using modules Jython works fine. Specifically, the following method works flawlessly in a basic project I created:
import org.python.core.PyObject;
import org.python.util.PythonInterpreter
public void pyth() {
try (PythonInterpreter pyInterp = new PythonInterpreter()) {
pyInterp.exec("x = 10+10");
PyObject x = pyInterp.get("x");
System.out.println(x.asInt());
}
}
However when I introduce module declarations in the project, Jython packages fail to be imported. I get the following error as soon as I add a module-info.java file:
Package 'org.python.core' is declared in module 'org.objectweb.asm', which does not export it to module
IntelliJ suggests me to add the following line in the Module Compiler Options
--add-exports org.objectweb.asm/org.python.util=<module-name>
--add-exports org.objectweb.asm/org.python.core=<module-name>
My question is, is there any other way to circumvent IntelliJ's suggested solution? Perhaps a missing dependency or plugin in the pom.xml file or a missing declaration in module-info.java?