How is language level determined for a library

I'm wondering how IDEA determines which language level that applies to the source code of a library.

I have a project with the following depencies: testCompile group: 'junit', name: 'junit', version: '4.12'

Language Level is set to SDK Default (i.e. Java 7) for my project. When I go to the source of org.hamcrest.Description @Override is flagged as error: (@Override is not allowed when implementing interfaces).

How does IDEA determine the language level of a library? Is it possible for libraries to have a language level that differs from the projects language level?


Hi Dirk,

version is retrieved from bytecode and it is of version 49 (= 1.5 language level). You may check it e.g. Find Action|Show Bytecode. In this case looks like sources and bytecode do not correspond to each other. I see the source of confusion here but I would rather disable the highlighting for library code at all than use project language level for them (Suppose one library is attached to 2 modules with different language levels, the same sources would be treated differently?).



I didn't think of class version information but this is a logical choice. Thanks for the explanation!


Please sign in to leave a comment.