Home > Software design >  Intellij - Package 'javax.smartcardio' is declared in module 'java.smartcardio',
Intellij - Package 'javax.smartcardio' is declared in module 'java.smartcardio',

Time:11-19

I'm in the process of upgrading a small spring boot application from Java 8 to Java 11. This project uses the package javax.smartcardio. I'm building it with maven.

The pom.xml basically contains the following dependencies/plugins:

  • spring-boot-starter-parent (2.5.6)
  • spring-boot-starter-test
  • spring-boot-starter-web
  • spring-boot-autoconfigure
  • pebble-spring-boot-2-starter
  • spring-boot-starter-security
  • spring-boot-maven-plugin
  • maven-resources-plugin
  • maven-assembly-plugin
  • exec-maven-plugin

After upgrading all my dependencies and using OpenJDK11 the project compiles and runs fine (mvn clean package). Especially the parts using the classes from javax.smartcardio also work fine.

Intellij however, is highlighting all my imports of the package javax.smartcardio. in red. When hovering over it, it tells me Intellij - Package 'javax.smartcardio' is declared in module 'java.smartcardio', which is not in the module graph. Intellij suggests to add this module via compiler options with --add-modules java.smartcardio. When doing so, Intellij stops highlighting the imports.

My question is now, why does Intellij highlight those imports, even though everything is compiling and running just fine nevertheless? What am I missing? Is it important to add that module when compiling? Maybe maven does something in that regard for me already? If so, which part should I lookout for?

I've read about using module-info.java, but came to the conclusion that using it to resolve my problem would not be the best solution. See also Any plans for Java 9 Jigsaw (module) of Spring projects?

CodePudding user response:

It is a known issue, please vote for IDEA-259485 Non-standard modules are not part of the class path in a non-modular module.

  • Related