java: diamond operator is not supported in -source 6
I’m having a weird issue with a larger project here. The above error message (and some more, see below) pops up when trying to run tests in IDEA (2021.3.3 on macOS). At first glance the solution looks simple: don’t use Java 7 features in Java 6.
My project is on Java 11, though. It is a multi-module Maven project, Java 11 is the only Java version installed on the machine, Java 6 doesn’t even exist for 64-bit macOS anymore, and I definitely have all the maven.compiler.target and maven.compiler.source properties set to “11”.
The messages from the build output window in total:
Executing pre-compile tasks…
Running 'before' tasks
Checking sources
Copying resources... [project-boot]
Copying resources... [project-oem]
Copying resources... [project-text]
Copying resources... [project-base-app]
Copying resources... [project-util]
Copying resources... [project-settings]
Copying resources... [project-hes]
Copying resources... [project-access]
Copying resources... [project-resources]
Copying resources... [project-ui]
Copying resources... [project-core]
Copying resources... [project-db]
Copying resources... [c-db]
Copying resources... [project-module]
Copying resources... [c-app]
Copying resources... [project-call]
Parsing java… [project-module]
java: source value 6 is obsolete and will be removed in a future release
java: To suppress warnings about obsolete options, use -Xlint:-options.
java: --add-opens has no effect at compile time
Parsing java… [tests of project-core]
Checking dependencies… [project-module]
Dependency analysis found 4 affected files
Errors occurred while compiling module 'project-module'
Writing classes… [tests of project-core]
Checking dependencies… [tests of project-core]
Dependency analysis found 0 affected files
Errors occurred while compiling module 'tests of project-core'
javac 11.0.14.1 was used to compile java sources
Finished, saving caches…
Compilation failed: errors: 1; warnings: 3
Executing post-compile tasks…
Synchronizing output directories…
13.04.22, 10:04 - Build completed with 3 errors and 68 warnings in 10 sec, 578 ms
So, apparently project-module is on Java 6. project-module’s POM doesn’t contain any version numbers at all, and its parent project, project-root, has the necessary settings to tell Maven that all’s Java 11.
This problem has been plaguing me for months with this project and I have no idea how to even find out further what the heck is happening here.
Do you have any ideas on how to find the root of this problem and/or maybe even how to fix it?
Thanks!
请先登录再写评论。
Can you show screenshot with the error you see?
What Java language target do you have set in IDE compiler settings: https://stackoverflow.com/a/32141090/2000323
and what java source level do you have set for each module in Project Structure Settings: