I was using Java 8 and Intellij 2018.1.1
I solved the issue in this way:
- open IntelliJ Idea settings
- navigate to Build, Execution, Deployment > Compiler > Java Compiler
- Uncheck the option:
Use '--release' option for cross-compilation (Java 9 and later)